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

相關文章
相關標籤/搜索