Jump to content

lil help with math


t0ddie
 Share

Recommended Posts

i just woke up and im thinking pretty slowly.

i want to make a stopwatch.

so it starts when the script starts and ends when the script closes. because timing may be off by just counting in an adlib function, i think the most accurate way is to get the system time at the start of the script and then get the time when it stops and determine the amount of time from those.

but i cant think of how to code it at the moment my math part of my brain isnt awake yet

any help?

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

something like that.

but if the time when you start is 1 : 19 : 12

and the time when you end is 1 : 22 : 22

there will be a negative number.

well i think i got it, just figure which is higher. then subtract from that for difference.

man, i just woke up... musta been this bowl of cheerios that did it

no wait... that might not give the proper time either damn it.. im still asleep!

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Well, it should be the end time - the start time. So if those times above, 1:19:12 and 1:22:22, are the start and end times, the script should tell you that you've run it for 3:12. There's no negative number there....

Also, if you have times that are longer than 24 hours (or 12 hours on that kind of clock), then you need to take into account the what day it is and/or whether it is AM or PM. You should never get a negative number.

Link to comment
Share on other sites

  • Developers

#include<date.au3>
; YourScript
Sleep(12345)
;
Func OnAutoItStart()
    Global $g_Timer = TimerInit() 
EndFunc  ;==>OnAutoItStart 
Func OnAutoItExit()
    Local $Hour, $Mins, $Secs
    _TicksToTime(Int(TimerDiff($g_Timer)), $Hour, $Mins, $Secs)
    $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
    MsgBox(0, "run time", $Time)
EndFunc  ;==>OnAutoItExit

:lmao:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...