Mastodon
Programmierung

Run a routine by name

[code lang=”delphi”]type
TExecute = procedure of object;

procedure TForm1.ExecuteRoutine(Instance: TObject; Name: string);
var
Routine: TMethod;
Execute: TExecute;
begin
Routine.Data := Pointer(Instance);
Routine.Code := Instance.MethodAddress(Name);
if Routine.Code = nil then Exit;
Execute := TExecute(Routine);
Execute;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ExecuteRoutine(DataModule2,’Hello’);
end;
[/code]

[tags]Delphi, Misc[/tags]

0 Kommentare zu “Run a routine by name

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.