zoukankan      html  css  js  c++  java
  • 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.
    View Code
  • 相关阅读:
    洛谷P2751 工序安排Job Processing
    UVA 1613 K度图染色
    线段树+扫描线
    分组背包
    洛谷P5506 封锁
    洛谷P2574 XOR的艺术
    List.Sort
    Dict.Count
    Convert.ToString(null) => null
    Convert 输入字符串的格式不正确
  • 原文地址:https://www.cnblogs.com/khzide/p/4460346.html
Copyright © 2011-2022 走看看