How can I make an infinite loop, that repeats every 30 seconds?
How can I make an infinite loop, that repeats every 30 seconds?
"SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
-Wizzup?
SCAR Code:repeat
dostuff;
wait(30000);
until(false);//never ending
thanks
"SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
-Wizzup?
That's assuming the "dostuff" will take less than 1 millisecond.
That would mean if the procedure DoStuff; had Wait(20000); it wouldn't repeat every 30 seconds would it. It would wait for 20 seconds, then wait for 30 seconds, totaling 50 seconds, then repeating.
Scripts: AIOCurser !, Tea Stall Thiever !, Flax Picker !
Other: Objective Functions, Scarduku
Tutorials: How to create a plugin for Simba, [VB.NET] Using My.Settings, [Photoshop] Basic Abstract Art
Outdated: m!ne v1.00 [STATS]
well technically he never said he wanted it to do stuff, he just said an infinite loop that repeats every 30 secs, so it'd be:
SCAR Code:repeat
wait(30*60000);
until(2+2=5);
that might only loop once, not sure![]()
![]()
SCAR Code:var
timerInt: Integer;
begin
repeat
TimerInt := GetTimeRunning + 30000;
DoStuff;
while (getTimeRunning < TimerInt) do
Wait(1);
until False;
end.
That will do something ~30s depending on how long doStuff takes.![]()
Writing an SRL Member Application | [Updated] Pascal Scripting Statements
My GitHub
Progress Report:13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you have serious physchological problems 13:46 <@BenLand100> HE GETS IT! 13:46 <@BenLand100> HE FINALLY GETS IT!!!!1
oops, I did 30 minutes, my bad lol.
And I already knew 2+2=22 (just kidding), that's why I put 5, cause he wants an infinite loop
I like nava's way, it does stuff and waits the amount of time left from the 30 secs, assuming it hasn't been 30 secs yet from doing stuff.
I dont understand what was wrong with the original posters way ?![]()
I may just be picky, but another way would be
A lot less wait calls and it should have, at most, <2ms over waiting depending on if/how much it takes to call Wait and process the second t := line. The positive t check is probably unneeded, but I like to have it in.SCAR Code:var
t: Integer;
begin
repeat
t := GetSystemTime;
DoStuff;
t := 30000 - (GetSystemTime - t);
if t > 0 then
Wait(t);
until false;
end.
Oh and the problem with the original suggestion was that if DoStuff took 5 seconds, then it would only call it every 35 seconds due to the 5 second for DoStuff and the 30 seconds for Wait().
By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.
There are currently 1 users browsing this thread. (0 members and 1 guests)