SRL Archive - SRL Bugs

TTimer issue


slushpuppy

2012-03-07 12:07:56

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

nickrules

2012-03-07 12:51:07

You forgot to create a TForm for it to run on ;)

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

E: I think…

bg5

2012-03-07 13:03:24


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.
// AddOnTerminate('DeleteTimer');
If you don't disable timer at the end ,Simba will crash.

masterBB

2012-03-07 13:14:50

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.

slushpuppy

2012-03-07 13:56:27

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

masterBB

2012-03-07 14:13:14

I believe it has something to do with this:
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.