topten Posted February 3, 2015 Posted February 3, 2015 Which is the best algo of time counting? For example I get innitial time of counting @HOUR @MIN . Say I have 17:45. For some time the script will need to sleep for X minutes and then continue on its work. Say I have 120 minutes of sleep or 210 minutes of sleep. Which is the best algo of calculating the time of script to continue? Great thanx in advance!
Solution Jewtus Posted February 3, 2015 Solution Posted February 3, 2015 Have you tried TimerDiff inside a do until statement? EX Do sleep(10) until TimerDiff($hTimer) > $timedelay
topten Posted February 3, 2015 Author Posted February 3, 2015 Ah, so nice! I didnt think of that! Thanx again!
johnmcloud Posted February 3, 2015 Posted February 3, 2015 (edited) Or: ; Johnmcloud _Wait(@HOUR, @MIN + 1) ; wait 1 minute ;_Wait(@HOUR + 2, @MIN) ; wait 2 hour = 120 minutes Func _Wait($iHour, $iMin) Do Sleep(1000) If @HOUR = $iHour And @MIN = $iMin Then ExitLoop Until 0 EndFunc ;==>_Wait Edited February 3, 2015 by johnmcloud
czardas Posted February 3, 2015 Posted February 3, 2015 (edited) LOL, I calculated the new time. Here's the code anyway. ; Local $sNewTime = TimeInterval("17:45", "09:16") MsgBox(0, "", $sNewTime) Func TimeInterval($sCurrentTime, $sInterval) Local $aHH_MM = StringSplit($sCurrentTime, ":"), $aTimeAdd = StringSplit($sInterval, ":") If Not (IsArray($aHH_MM) And IsArray($aTimeAdd)) Then Return SetError(1) If $aHH_MM[0] <> 2 Or $aTimeAdd[0] <> 2 Then Return SetError(2) Local $iHours = $aHH_MM[1] + $aTimeAdd[1], $iMins = $aHH_MM[2] + $aTimeAdd[2] If $iMins > 59 Then $iHours += 1 $iHours = Mod($iHours, 24) $iMins = Mod($iMins, 60) Return StringFormat("%02i:%02i", $iHours, $iMins) EndFunc Edited February 3, 2015 by czardas operator64 ArrayWorkshop
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