Jump to content

A couple questions


Divine
 Share

Go to solution Solved by michaelslamet,

Recommended Posts

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

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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 by michaelslamet
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...