Results 1 to 3 of 3

Thread: Trouble with using TTImer.

  1. #1
    Join Date
    May 2012
    Location
    Moscow, Russia
    Posts
    661
    Mentioned
    35 Post(s)
    Quoted
    102 Post(s)

    Default Trouble with using TTImer.

    Hi everyone. I'l try use TTimer in my script. Is write next code:
    Code:
    var
    Timer: TTimer;
    
    procedure MyProc;
    begin
     writeln('Timer is work');
    end;
    
    procedure Proc(Sender: TObject);
    begin
     If (Sender = Timer) then
      MyProc;
    end;
    
    procedure InitTimer;
    begin
      Timer := TTimer.Create(nil);
      Timer.Interval := 1000;
      Timer.OnTimer := @Proc;
      Timer.Enabled :=true;
    end;
    begin
     InitTimer;
    end;
    - that compile fine but isn't work. How i can use TTimer in my script?
    Per aspera ad Astra!
    ----------------------------------------
    Slow and steady wins the race.

  2. #2
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Added Proc(Timer); and full stop on mainloop.
    Simba Code:
    var
    Timer: TTimer;

    procedure MyProc;
    begin
     writeln('Timer is work');
    end;

    procedure Proc(Sender: TObject);
    begin
     If (Sender = Timer) then
      MyProc;
    end;

    procedure InitTimer;
    begin
      Timer := TTimer.Create(nil);
      Timer.Interval := 1000;
      Timer.OnTimer := @Proc;
      Timer.Enabled :=true;
    end;

    begin
     InitTimer;
     Proc(Timer);
    end.

    This is the debug -
    Progress Report:
    Compiled successfully in 16 ms.
    Timer is work
    Successfully executed.

  3. #3
    Join Date
    May 2012
    Location
    Moscow, Russia
    Posts
    661
    Mentioned
    35 Post(s)
    Quoted
    102 Post(s)

    Default

    Tnx.
    Per aspera ad Astra!
    ----------------------------------------
    Slow and steady wins the race.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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