Sign in to follow this  
Followers 0
Therapist

Do until.

5 posts in this topic

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



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

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 game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

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

Thank 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

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0