Jump to content

Timer related Functions


Fend
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...