Jump to content
Sign in to follow this  
Fend

Timer related Functions

Recommended Posts

Fend

Ok, So lets say I want to timeout of a while loop If a condition is not met...

If(some condition) Then

$begin = TimerInit()

While(some other condition)

Sleep(50)

If(TimerDiff($begin)=60000) Then

ExitLoop

EndIf

WEnd

EndIf

I am at work and unanle to test this, would this work or is there a better function to achieve this?

I could allways increment a variable after each sleep and have it exit loop when the variable is 1200, but it just seems a bit sloppy to me...any advice?


I like cookies?

Share this post


Link to post
Share on other sites
sandin

the only thing you should change is timerdif, make it

If TimerDiff($begin) >= 60000 Then ExitLoop

if you make it only "=" then the script will work ONLY if the timer diff. mach 60000, and since you are using sleep(50) there are high chances of your script missing timerdif "=" 60000

if you are using only one command after IF, using 3 lines is not necessary, you can use only one like, like the one I used.

Share this post


Link to post
Share on other sites
Fend

the only thing you should change is timerdif, make it

If TimerDiff($begin) >= 60000 Then ExitLoop

if you make it only "=" then the script will work ONLY if the timer diff. mach 60000, and since you are using sleep(50) there are high chances of your script missing timerdif "=" 60000

if you are using only one command after IF, using 3 lines is not necessary, you can use only one like, like the one I used.

That make perfect sense, thank you!

I like cookies?

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  

×