Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all, let's say I have

Status
Not open for further replies.

alphonsus

Technical User
Dec 18, 2000
16
0
0
BR
Hi all,

let's say I have a Form with an Edit box and some public methods. The
user will type the name of the method in the Edit box and the program will
execute it. In other words: in Runtime I need to execute a method having
only it's name as a String.

Any help???
Thanks,
Alphonsus.
 
i don't think (but am not sure) it is possible to execute a method having only it's name as a String.

What you could do (if the number of methods is not to big) is something like:

if edit1.text = 'method1' then
method1()
else if edit1.text = 'method2' then
method2();

 
You can do that only if the methods are 'published', not 'public'...

procedure TForm1.Button1Click(Sender: TObject);
var p:pointer;
begin
p:=myClass.MethodAddress(edit1.text);
if p<>nil
then asm
call dword ptr p
end;
end;

I hope it's what you wanted...
Raz
 
Yes Raz, this is what I need. Is it possible to pass parameters???

Thanks a lot,
Alphonsus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top