fastscript传递参数

fastscript传递参数html

{这个脚本功能恐怕不多人用到过,因此没人回答你…
你的脚本不正确,你要先在程序中能正常执行,再放到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.htm

{程序代码:}
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;blog

finally
   fs.Free;
 end;
end;ip

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

相关文章
相关标签/搜索