mother9987 Posted November 15, 2007 Share Posted November 15, 2007 I'm having a problem with TimerDiff. The problem is: I have one script that runs and I need to mark when it gets to a certain point. Then some time later (could be milliseconds later so precision is important) a second script runs and it needs to know how long has elapsed since the first script hit its magic marking point. What does not work (but I want to achieve and equivalent to): Script1 ... FileWriteLine( "TempFile", TimerInit() ) ... Script2 ... $TimeElapsed=TimerDiff( FileReadLine( "TempFile" ) ) ... I tried wrapping the value retrieved from TimerInit in Binary and other conversions before writing it to the file with no success. And there's no notes on the TimerInit or TimerDiff function on how the systemclock is represented in the output/input to those functions... So, is there a way to export the value from TimerInit that is readable later? Or alternately, is there a simple way to read the system clock to find the number of milliseconds elapsed since midnight that I could just do whatever I want with? Thanks for any help! Mother Link to comment Share on other sites More sharing options...
Valuater Posted November 15, 2007 Share Posted November 15, 2007 Maybe.. $begin = TimerInit() $begin2 = TimerInit() sleep(3000) $dif = TimerDiff($begin) MsgBox(0,"Time Dif #1",$dif) sleep(1000) $dif = TimerDiff($begin2) MsgBox(0,"Time Dif #2",$dif) 8) Link to comment Share on other sites More sharing options...
weaponx Posted November 15, 2007 Share Posted November 15, 2007 The original code worked fine for me but the timediff returned was incorrect (should have been 1000, shows 2000), use an ini instead. IniWrite ( "timestamp.ini", "lastrun", "timestamp", TimerInit()) Sleep(1000) $TimeElapsed = TimerDiff(IniRead ( "timestamp.ini", "lastrun", "timestamp", "" )) MsgBox(0,"",$TimeElapsed) Link to comment Share on other sites More sharing options...
mother9987 Posted November 15, 2007 Author Share Posted November 15, 2007 Ok, another case of me being stupid... There's these things called parenthesis that are good to use in math formulas with you want to do things like divide a difference of two numbers. i.e. (TimerDiff( $time1 ) - TimerDiff( $time2 ) ) / 1000... those outer parenthesis are important! Sorry for the bother with a dumb problem. Link to comment Share on other sites More sharing options...
Valuater Posted November 15, 2007 Share Posted November 15, 2007 ; They just mean "what is done first" $time1 = TimerInit() Sleep(3000) $time2 = TimerInit() Sleep(2000) $ans = Int((TimerDiff( $time1 ) - TimerDiff( $time2 ) ) / 1000) MsgBox(0x0,"Answer", $ans & " Seconds ") Exit 8) Link to comment Share on other sites More sharing options...
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