SRL Archive - OSR Help

Run a procedure outside of whatever is being ran...


vanlacke

2013-08-16 20:22:34

Very hard to explain and likely not possible.. However it's worth a shot.

Is a way to run a procedure, say, every 10 seconds, and have it run universally regardless of where the script is currently running?

Hope that was understandable. I seem to remember finding a tutorial that explained a 'pseudo' method for this, however I haven't been able to find it. Currently I am simply calling the procedure in every single procedure/function that will be used, but it's getting rather tedious to manage.

rj

2013-08-16 20:26:04

Are you talking about multithreading? Simba can't do this :s

vanlacke

2013-08-16 21:02:46

From: Officer Barbrady
Are you talking about multithreading? Simba can't do this :s


Yes multithreading sounds like the right term… bummer!

Wu-Tang Clan

2013-08-16 21:22:27

While… do
Not totally sure if thats what you are looking for

Daniel

2013-08-17 06:52:45

You could use the TTimer component, however Windows gives that a very low priority when sending messages to applications and vice versa.


program new;

var
Timer: TTimer;
Params: TVariantArray; // Useless, but required...

procedure OnTimer(Sender: TObject);
begin
// Procedure to repeat every ten seconds here...
end;

procedure InitialiseTimer;
begin
Timer := TTimer.Create(nil);
Timer.Interval := 10000; // Every ten seconds.
Timer.OnTimer := @OnTimer;
Timer.Enabled := True;
end;

begin
ThreadSafeCall('InitialiseTimer', Params);

repeat
Sleep(1000);
Until(False);

Timer.Free;
end.

However, it runs on the main-thread, and Simba for some silly reason unbinds the Writeln called from within PascalScript to the native one which prints text to the console, and not the debug box. Apart from that, it should be okay.

vanlacke

2013-08-19 04:26:24

From: Daniel
You could use the TTimer component, however Windows gives that a very low priority when sending messages to applications and vice versa.


program new;

var
Timer: TTimer;
Params: TVariantArray; // Useless, but required...

procedure OnTimer(Sender: TObject);
begin
// Procedure to repeat every ten seconds here...
end;

procedure InitialiseTimer;
begin
Timer := TTimer.Create(nil);
Timer.Interval := 10000; // Every ten seconds.
Timer.OnTimer := @OnTimer;
Timer.Enabled := True;
end;

begin
ThreadSafeCall('InitialiseTimer', Params);

repeat
Sleep(1000);
Until(False);

Timer.Free;
end.

However, it runs on the main-thread, and Simba for some silly reason unbinds the Writeln called from within PascalScript to the native one which prints text to the console, and not the debug box. Apart from that, it should be okay.


Ah yes! This is what I found before. Found it again just now thanks to you: http://villavu.com/forum/showthread.php?t=51578

Thanks

Mark

2013-08-19 09:05:29

From: Daniel
You could use the TTimer component


has this been fixed now as last i heard this was broken since scar still correct? or is this now working under lape?