I'm mainly curious about the application at this point. Is it possible that you're going the long way around to doing something that would be syntactically easier (and more portable) done a different way?
For example, just make the "task" a class, and just override the method which does the work for whatever specific task you want to do by inheritance.
Code:
Type
TMyTask = class
Procedure DoStuff; Virtual; Abstract;
End;
TMyTextTask = class(TMyTask)
Procedure DoStuff; Override;
End;
TMySoundTask = class(TMyTask)
Procedure DoStuff; Override;
End;
Var
MyTask : TMyTask;
Command : String;
Procedure TMyTextTask.DoStuff;
Begin
Writeln('Hi there!');
End;
Procedure TMySoundTask.DoStuff;
Begin
PlaySound('SystemQuestion', 0, SND_ALIAS or SND_ASYNC);
End;
Begin
MyTask := Nil;
Command := LowerCase(ParamStr(1));
If Command = 'text' Then
MyTask := TMyTextClass.Create;
Else
If Command = 'sound' Then
MyTask := TMySoundClass.Create;
If (Assigned(MyTask)) Then
MyTask.DoStuff;
End.
Does something like that make more sense?
Bookmarks