Therapist Posted September 3, 2011 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
monoscout999 Posted September 3, 2011 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
kaotkbliss Posted September 3, 2011 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 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
Therapist Posted September 3, 2011 Author 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 ...
Therapist Posted September 3, 2011 Author 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,
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now