This is only a paranoia question...
When using millisec(), does it have a maximum value that then reached resets the counter back to zero?
When using millisec(), does it have a maximum value that then reached resets the counter back to zero?
Local Milli:Long=Long(MilliSecs())+4294967296:Long
Graphics 800, 600, 0, 2 Const MAX_POSITIVE = 2147483647 Const MAX_NEGATIVE = -2147483648 current_time = MAX_POSITIVE deadline_time = MAX_POSITIVE + 1 ;current_time = -1 ;deadline_time = 0 ;Print "Millisecs() wrapover occurs every " + ( ( ( ( MAX_POSITIVE / 1000.0 ) / 60.0 ) / 60.0 ) / 24.0 ) + " days." Print Print "current_time = " + current_time Print "deadline_time = " + deadline_time Print Print "Time remaining = " + ( deadline_time - current_time ) Print ; -- Check if 'current_time' has exceeded 'deadline_time'. This should work even if one or both times have ;~ wrapped over to negative, or if one or both times have wrapped from negative to zero or positive. ;~ Substitute '>=' for '>' when testing if 'current_time' has reached or exceeded 'deadline_time'. If ( current_time - deadline_time ) > 0 Print "Timeout occurred" Else Print "No timeout occurred" EndIf ;^^^^^^ WaitKey () End
Strict Global newtime:Int = MilliSecs() Global oldtime:Int = MilliSecs() Global elapsedtime:Int = 0 Repeat oldtime = newtime newtime = MilliSecs() If oldtime < newtime Then 'using 2147483648 to make sure newtime and oldtime are positive all the time. elapsedtime = (2147483648 + newtime) - (2147483648 + oldtime) Else 'In case if the newtime is smaller than the oldtime (after reset) this calculation is done to make sure you get the correct elapsed time. elapsedtime = (2147483648 + newtime) - (oldtime - 2147483648) EndIf Delay 5000 Print elapsedtime + " MilliSecs elapsed after last print command!" Until KeyHit(Key_ESCAPE)