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}

转载于:https://www.cnblogs.com/chenlala/archive/2013/01/08/2851841.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值