case s of
intostr:result:intotostr(54);
strtoint:result:=strtoint('54')
end;

解决方案 »

  1.   

    copy 过来的。
    这方法只有在类里面的方法或函数才可实现,如果是单元公共过程或函数就不知了。 
    像SysUtils里面的过程和函数就无法实现了,不知各位还有没高招?
    type
     {$M+}
      TMyObj = class
      published
        function CommandOne: Integer;
        function CommandTwo: Integer;
        function CommandThree: Integer;
        function CommandFour: Integer;
      end;
     {$M-}function DoCommand1(const Command: string): Integer;
    var
     CommandProc: function: Integer of object;
    begin
      TMethod(CommandProc).Code := TMyObj.MethodAddress(Command);
      if Assigned(TMethod(CommandProc).Code) then Result := CommandProc;
    end;-- 
    WBR, LVT.PS: A second method by V.Titov :uses
      TypInfo;type
      TCommand = (CommandOne, CommandTwo, CommandThree, CommandFour);function DoCommand2(const Command: string): Integer;
    begin
      Result := 0;
      case TCommand(GetEnumValue(TypeInfo(TCommand), Command)) of
          CommandOne: ..;
          CommandTwo: ..;
        CommandThree: ..;
         CommandFour: ..;
      end;
    end;
      

  2.   

    呵呵,这样的事需要RTTI的支持,因此,除非类中的Property部分,否则是没有办法这样访问的。
      

  3.   

    象你这样就把一个字符串当作一个函数了,你说呢?INTTOSTR不是一个字符串。
    s(54)怎么解释?
      

  4.   

    类和记录差不多
    但是前提是IntToStr这样的函数有限个。