Sign in to follow this  
Followers 0
t0ddie

lil help with math

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



so ur saying u want something to record the time when u start a script then when it ends record, that time and then subtract them to see how many hours it ran?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#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:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks jdeb


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0