Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Pointers, objects, functions and execution - is this even possible?

  1. #11
    the code LifePower posted will work... to pass params in the asm block you just need to use push

  2. #12
    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?

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •