hot202 Posted August 31, 2010 Share Posted August 31, 2010 hi how would i skip a func in my while loop and only use that func every hour i my loop? Link to comment Share on other sites More sharing options...
Varian Posted August 31, 2010 Share Posted August 31, 2010 Try this is a jumping off point Local $NowHour While 1 If Not $NowHour Or $NowHour <> @HOUR Then YourFunction() $NowHour = @HOUR EndIf Sleep(1000) ;Sleep 1 second WEnd Link to comment Share on other sites More sharing options...
hot202 Posted August 31, 2010 Author Share Posted August 31, 2010 would this still work if im doing other stuff in the while loop. so it just checks to see if its been a houre after everything if not it willstilldo other stuff and if its been the hour it willdo my func? Link to comment Share on other sites More sharing options...
kaotkbliss Posted August 31, 2010 Share Posted August 31, 2010 (edited) just a slight change... Local $NowHour While 1 If Not $NowHour Or $NowHour <> @HOUR Then YourFunction() $NowHour = @HOUR EndIf ;do other code here Sleep(10) ;shortend the sleep for less pause between checking and doing stuff WEnd Edited August 31, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Varian Posted August 31, 2010 Share Posted August 31, 2010 (edited) would this still work if im doing other stuff in the while loop. so it just checks to see if its been a houre after everything if not it willstilldo other stuff and if its been the hour it willdo my func?Pretty much, but if you want ALL runs of your function to be 60 minutes (give or take however long the rest of your code in your loop) to process, you will need to look at timer functions like TimerInint() & _TimerDiff(); If you start this script at 12:59PM, the next run will be when the hour is at 13(1PM) so the first 2 runs would only be one minute apart. The subsequent runs would be roughly 60 minutes apart. You could remedy this by storing the Hour & minute and then check to see if the hour has changed and the minute is the same (12:59 to 1:59 to 2:59, etc) or measuring the TimerDiff so it is 60 minutes Edited August 31, 2010 by Varian Link to comment Share on other sites More sharing options...
Varian Posted August 31, 2010 Share Posted August 31, 2010 (edited) Here is an example with TimerInint(); This solves the afore mentioned dilemma $Begin = TimerInit() While 1 $Dif = Floor(TimerDiff($Begin) / 60000) ;Returns Elapsed Time in minutes If $Dif = 60 Then YourFunction() $Begin = TimerInit() ;resets the timer EndIf ;Rest of your Script Here Sleep(10) ;small idle to avoid CPU throttling WEnd Edited August 31, 2010 by Varian 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