调用自己程序中的函数,如果函数不多,匹配下还是可以吧/if Edit.Text ='MyFunctionName1' then MyFunctionName(p1,p2) else if Edit.Text ='MyFunctionName2' then MyFunctionName2(P1,P2) else ....
如果这些函数位于published域,则处理很方便。比如: TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); //…… published procedure Fun(X: Integer); end; TFun = procedure (X: Integer); procedure TForm1.Button1Click(Sender: TObject); var X: string; M: Pointer; F: TFun; begin X := Edit1.Text; M := MethodAddress(X); if M <> nil then begin @F := M; F(1); end; end;procedure TForm1.Fun(X: Integer); begin ShowMessage(IntToStr(X)); end;———————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 ————————————————————————————————————
上Google去找了
MyFunctionName(p1,p2)
else if Edit.Text ='MyFunctionName2' then
MyFunctionName2(P1,P2)
else ....
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
//……
published
procedure Fun(X: Integer);
end; TFun = procedure (X: Integer);
procedure TForm1.Button1Click(Sender: TObject);
var
X: string;
M: Pointer;
F: TFun;
begin
X := Edit1.Text;
M := MethodAddress(X);
if M <> nil then
begin
@F := M;
F(1);
end;
end;procedure TForm1.Fun(X: Integer);
begin
ShowMessage(IntToStr(X));
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
www.yixel.com 带有例子的,用LexLib你也可以自己封装一个简化函数:Run('MessageBox','0,"Hello world","Caption",0');
firef(火狐) 的方法可以用,刚开始我就是这样用的,不过函数太多,写的太累。
IFPS和LexLib都下到了,研究中。
现在用 lxpbuaa(桂枝香在故国晚秋) 的办法,把那些函数包装到了一个类里。