Results 1 to 6 of 6

Thread: TTimer issue

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default TTimer issue

    Simba Code:
    program New;
     {$DEFINE SRL5}

    {$i srl/srl.simba}
    var
       Timer: TTimer;

    Procedure hi(Sender: TObject);

    begin
      writeln('hi');
    end;

    Procedure CreateTimer;

    Begin
      Timer := TTimer.Create(nil);
      Timer.Interval := 2000;
      Timer.Enabled := True;
      Timer.OnTimer := @hi;
    End;

    Procedure DeleteTimer;

    Begin
      Timer.Enabled := False;
      Timer.Free;
    End;

    Procedure ScriptTerminate;

    Var
       V: TVariantArray;

    Begin
      SetLength(V, 0);
      ThreadSafeCall('DeleteTimer', V);
     // AddOnTerminate('DeleteTimer');
    End;

    Var
       V: TVariantArray;
       t: integer;
    begin
      SetLength(V, 0);
      ThreadSafeCall('CreateTimer', V);
      t := getsystemtime;
      Repeat
        Wait(100);
      Until getsystemtime - t > 8000;
    end.

    It seems the timer isn't running or procedure "hi" isn't being called as there is no output in the console

  2. #2
    Join Date
    May 2008
    Location
    ;)
    Posts
    576
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You forgot to create a TForm for it to run on

    check out http://villavu.com/forum/showthread.php?t=51578

    E: I think...
    Last edited by nickrules; 03-07-2012 at 06:24 PM.

  3. #3
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    It seems the timer isn't running or procedure "hi" isn't being called as there is no output in the console
    No output in console? :P


    Btw.
    Simba Code:
    // AddOnTerminate('DeleteTimer');
    If you don't disable timer at the end ,Simba will crash.
    Last edited by bg5; 03-07-2012 at 06:06 PM.

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Writeln doesn't write on the simba output box. All the other functions will work fine as long as you don't use a var with a timer and the standard loop at once.
    Working on: Tithe Farmer

  5. #5
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Oh. i had that command prompt hidden xD. Before anyone closes this, Why doesn't it appear to the simba bottom console

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    I believe it has something to do with this:
    Simba Code:
    procedure TClient.WriteLn(s: string);
    begin
      if (self <> nil) and Assigned(WritelnProc) then
        WritelnProc(s)
      else
        mDebugLn(s);
    end;

    Maybe the timer calls it at a different way using the mDebugLn(s) instead.
    Working on: Tithe Farmer

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
  •