SRL Archive - OSR Help

How to end a loop after a duration of time?


yamaha317

2011-03-02 18:58:20

So I would like to end certain loops after 30 sec, 60 sec, and 120 seconds. I was wondering how to set this up. I think this can be done using the system time functions but I cant quite figure it out.

Thanks for any input.

Narcle

2011-03-02 19:00:24

T := GetsystemTime;
repeat
wait(1);
until ((GetSystemTime - T) >= 30000);

Edit:
Or break loop

repeat
wait(1);
if ((GetSystemTime - T) >= 30000) then
Break;
until false;

NCDS

2011-03-02 19:02:36



procedure DoForTime;
var
t: Integer;
begin
t := GetSystemTime + 30000; //Set 't' equal to 30 seconds from now
while t > GetSystemTime do
begin
ThisIsA;
30SecondLoop;
end;
end;
Quite simple, you see? :)

Also, stick with one thread next time please.

From the other thread..

yamaha317

2011-03-02 20:40:38

Much appreciated. Thank you so much, once again I apologize for the double post.

Wanted

2011-03-02 21:24:15

another way

T := GetSystemTime;
while ((GetSystemTime - T) < 10000) do
begin
//stuff;
end;

WT-Fakawi

2011-03-04 04:27:33

Or you can use Stupid3ooo's Marktime and TimeFromMark… still in SRL :D

Wanted

2011-03-05 01:36:46

From: WT-Fakawi
Or you can use Stupid3ooo's Marktime and TimeFromMark… still in SRL :D


I remember when scripts used to use MarkTime, ha. It's literally the same thing though for anyone wondering.