fastscript 经验集
implementation type TFunctions = class(TfsRTTIModule) private function CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; Caller: TfsMethodHelper): Variant; public constructor Create(AScript: TfsScript); override; end; { TFunctions } function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; Caller: TfsMethodHelper): Variant; begin Result := 0; if MethodName = 'ONEKEY' then FrmMain.OneKey(Caller.Params[0],Caller.Params[1],Caller.Params[2],Caller.Params[3]) else if MethodName = 'ONEKEY2' then FrmMain.OneKey(Caller.Params[0],Caller.Params[1]) else if MethodName = 'GETTEXT' then Result := FrmMain.GetText(Caller.Params[0]) else if MethodName = 'NEXTLINE' then FrmMain.NextLine else if MethodName = 'SLEEP' then Sleep1(FrmMain.se.Value) else if MethodName = 'QUERYCANCEL' then Result := FrmMain.FCancel; end; constructor TFunctions.Create(AScript: TfsScript); begin inherited Create(AScript); AScript.AddMethod('procedure OneKey(key1:Byte; ext1:Boolean;key2:Byte; ext2:Boolean)', CallMethod); AScript.AddMethod('procedure OneKey2(key:Byte; ext:Boolean = false)', CallMethod); AScript.AddMethod('function GetText(i: Integer):string', CallMethod); AScript.AddMethod('procedure NextLine', CallMethod); AScript.AddMethod('procedure sleep', CallMethod); AScript.AddMethod('function querycancel:boolean', CallMethod); end; initialization fsRTTIModules.Add(TFunctions); finalization fsRTTIModules.Remove(TFunctions); end.