Divine Posted December 18, 2013 Posted December 18, 2013 Would the $RunTime variable actually be affected by the arithmetic, or will I have to write a separate variable for that in the following code? Global $StartTime ; Somewhere in my code $StartTime = TimerInit() Func getTime() $RunTime = TimerDiff($StartTime) $amtHour = $RunTime/3600000 ; Rest of stuff EndFunc And how do I round off a number? $hour = 5752354 $amtHour = $hour/3600000 I want it to return a whole number, not a decimal and leave the remainder to perform other arithmetic
Solution michaelslamet Posted December 18, 2013 Solution Posted December 18, 2013 Hi Divine, In your example, $RunTime will not affected by the arithmatic. To Round a number, you can use Round(), Ceiling(), Floor() or StringFormat()
Divine Posted December 19, 2013 Author Posted December 19, 2013 Hi Divine, In your example, $RunTime will not affected by the arithmatic. To Round a number, you can use Round(), Ceiling(), Floor() or StringFormat() Would the following code successfully format the runtime? $RunTime = TimerDiff($BeginTime) $aHour = Floor($RunTime / 3600000) $RunTime = $RunTime - ($aHour * 3600000) $aMinute = Floor($RunTime / 60000) $RunTime = $RunTime - ($aMinute * 60000) $aSecond = Floor($RunTime / 1000)
michaelslamet Posted December 19, 2013 Posted December 19, 2013 (edited) You might want to take a look at _TicksToTime() Something like this: #include <date.au3> Local $BeginTime = TimerInit() Local $RunTime, $Hour, $Minute, $Second Sleep(Random(1000,90000,1)) $RunTime = TimerDiff($BeginTime) _TicksToTime($RunTime, $Hour, $Minute, $Second) ConsoleWrite($RunTime & @CRLF & $Hour & @CRLF & $Minute & @CRLF & $Second & @CRLF) Edit: add a example (code) Edited December 19, 2013 by michaelslamet
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