Fend Posted January 7, 2009 Share Posted January 7, 2009 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 More sharing options...
sandin Posted January 7, 2009 Share Posted January 7, 2009 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. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Fend Posted January 7, 2009 Author Share Posted January 7, 2009 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 More sharing options...
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