"Claus Christiansen" <cch@unipeople.dk> wrote in message
news:f6Ti6.4824$PC4.171696@news010.worldonline.dk...
>
> "Thomas P" <blomme@post.com> wrote in message
> news:96go41$m6l$1@news.inet.tele.dk...
> > > Alternativt kan du skifte til Java og så bruge reflection
> >
> > Well... så kunne han jo ikke spørge denne geniale newsgroup om hjælp
> mere -
> > så hellere blive
>
> Mere enig kan man da ikke være.... :) og så burde GOTO været fjernet
> allerede med D1!!
og derudover
* I can use LoadLibrary()/GetProcAddress() to call a function in a .DLL.
* Is there a similar way that I can call a function in the current
* application based on a string variable that contains the function name?
*
** Yes, if you export the function (just like a DLL) and have an exports
** clause in the dpr, then you can use GetProcAddres as normal (no need to
** load library - it is loaded), the Handle is that returned by
** GetCurrentTask, NOT application.handle.
**
** e.g.
**
** @Routine=GetProcAddress(GetCurrentTask,'MyRoutine');
eller (et eks. der ikke er helt pænt, men det skulle vist kunne vise
teknikken) - variablen m, skal selvfølgelig lige sættes til en instans af
TMethods
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
end;
TMethod = procedure;
TMethods = class
published
procedure A;
procedure B;
end;
var
m: TMethods;
procedure TForm1.Button1Click(Sender: TObject);
var
method: TMethod; { or whatever the method 'type' is }
begin
method := m.MethodAddress(edit1.text);
{ execute method by casting it to the appropriate method type }
TMethod(method);
end;
procedure TMethods.A;
begin
Form1.listbox1.items.add('A');
end;
procedure TMethods.B;
begin
Form1.listbox1.items.add('B');
end;
Claus
--
Claus Christiansen, TeamD member <cch@unipeople.dk>
Pythia:
http://www.pythia.dk
Personal:
http://www.bigfoot.com/~kruc
============================================-------------------------
"Gravitation can not be held responsible for people falling in love"
A. Einstein