Sign in to follow this  
Followers 0
Scinner

While...WEnd loop time limited?

8 posts in this topic

Is there a way to time limit a While WEnd loop? Eg. do this until 4 minutes have passed.

Share this post


Link to post
Share on other sites



Dim $iInit = TimerInit()

Do
.
.   If $fSatisfied Then ExitLoop
.
Until TimerDiff($iInit)/1000 > 4*60oÝ÷ Ûú®¢×£&m«`¢Z¶Øb²ì¥tÈiÖ­¶¬jëh×6Dim $iInit = TimerInit()

Do
While 1
;some malicious code here ;)
   If $fSatisfied Then ExitLoop
WEnd
Until TimerDiff($iInit)/1000 > 4*60

Should it look like that and if so, what do I declare $fSatisfied as?

Share this post


Link to post
Share on other sites

u are putting the while loop inside the do until. Get rid of the while loop and it will work. $satisfied is whatever you want it to be to make it exit you loop.

Dim $iInit = TimerInit()
Do
;put what you want to run for 4 minutes in here, no while loop is needed, the Do Until takes care of it
Until TimerDiff($iInit)/1000 > 4*60

Share this post


Link to post
Share on other sites

u are putting the while loop inside the do until. Get rid of the while loop and it will work. $satisfied is whatever you want it to be to make it exit you loop.

Dim $iInit = TimerInit()
Do
;put what you want to run for 4 minutes in here, no while loop is needed, the Do Until takes care of it
Until TimerDiff($iInit)/1000 > 4*60
What the .... ?

Dim $iInit = TimerInit()
While TimerDiff($iInit)/1000 < 4*60
;put what you want to run for 4 minutes in here, no while loop is needed, the Do Until takes care of it
Wend

The only argument able difference between Do .. Until and While .. Wend is that Do .. Until always executes at least once, because the expression is checked at the end of the loop instead of at the start.

Share this post


Link to post
Share on other sites

Do
While 1
;some malicious code here wink.gif
   If $fSatisfied Then ExitLoop
WEnd
Until TimerDiff($iInit)/1000 > 4*60

I was commenting on him having the While inside the do until. I realize he could have just used a while.

Share this post


Link to post
Share on other sites

u are putting the while loop inside the do until. Get rid of the while loop and it will work. $satisfied is whatever you want it to be to make it exit you loop.

Dim $iInit = TimerInit()
Do
;put what you want to run for 4 minutes in here, no while loop is needed, the Do Until takes care of it
Until TimerDiff($iInit)/1000 > 4*60
Thank you for explaining!!

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