Therapist 0 Posted September 3, 2011 I hope this can be done, I need an until 'expression' that makes the sub loops last only for the desired amount of time and then end. I cant use sleep as it has no return And (at my current knowledge) can not use timer's, as time will be different for every sub loops.While 1 $Time =Random(5000,10000) Do . . . Until <expression> ; I want this loop to continue for $Time millisec's WEnd Thanks in advanced Share this post Link to post Share on other sites
monoscout999 10 Posted September 3, 2011 Why cannot use a timer? global $timer While True $timer = TimerInit() Do ; Until TimerDiff($timer) > 3000 ; tree seconds WEnd But if you want to do it only once global $timer, $check = True While True If $check then $timer = TimerInit() Do sleep(500) consolewrite(TimerDiff($timer)&@crlf) Until TimerDiff($timer) > 3000 ; tree seconds $check = not $check EndIf WEnd Share this post Link to post Share on other sites
kaotkbliss 146 Posted September 3, 2011 Why is it in a while 1 infinate loop? it will only make the code go back into the do..until loop when it meets the expression. $Time =Random(5000,10000)$timer = TimerInit()Do...Until TimerDiff($timer) >= $Time 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
Therapist 0 Posted September 3, 2011 Why cannot use a timer? global $timer While True $timer = TimerInit() Do ; Until TimerDiff($timer) > 3000 ; tree seconds WEnd Oh Thanks A tonne ), It seems I underestimated the timer function ... Share this post Link to post Share on other sites
Therapist 0 Posted September 3, 2011 Why is it in a while 1 infinate loop? it will only make the code go back into the do..until loop when it meets the expression. $Time =Random(5000,10000)$timer = TimerInit()Do...Until TimerDiff($timer) >= $TimeThank you as well, I have a script that need to loop and have functions that need need to also loop within the main loop. Regards, Share this post Link to post Share on other sites