fastscript传递参数

{这个脚本功能恐怕很少人用到过,所以没人回答你…
你的脚本不正确,你要先在程序中能正常执行,再放到txt中

下面例子只测试1个参数,其它参数自己处理,自己参考着改吧:
D:\1.txt脚本:}
Function ChkDate(li_Year,li_Month,li_Day:Integer):Integer;
begin
Result:=0;
if Length(IntToStr(li_Year))>4 then
begin
ShowMessage('不是正确的年份');
Exit;
end;
Result:=li_Year*365;
end;

begin
end.

{程序代码:}
function GetDayNum(ls_ScriptPath:string;li_Year,li_Month,li_Day:Integer):Integer;
var
fs:TfsScript;
begin
Result:=0;
if not fileexists(ls_ScriptPath) then
Exit;
fs:=TfsScript.Create(nil);
try
fs.Parent:=fsGlobalUnit;
fs.Lines.LoadFromFile(ls_ScriptPath);
if fs.Compile then
begin
fs.FindLocal('ChkDate').Params[0].Value:=li_Year; {其它参数类似赋值}
Result:=fs.FindLocal('ChkDate').Value; {脚本中函数ChkDate的返回值}
end;

finally
fs.Free;
end;
end;

ShowMessage(IntToStr(GetDayNum('D:\1.txt',2,1,1))); {结果730 即2*365}

posted on 2013-01-08 21:03  chenlala  阅读(228)  评论(0编辑  收藏  举报

导航