| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| TIME AND TIMERS https://mail.black-squirrel.com/viewtopic.php?f=15&t=25540 |
Page 1 of 1 |
| Author: | Yop_Solo [ Wed Jan 20, 2010 1:36 pm ] |
| Post subject: | TIME AND TIMERS |
Hi to all TW scripters, I would like to generate a timer to know how long my script is running. Code: SETVAR $STEP1 TIME SETVAR $STEP11 TIME SETVAR $TotalTime $STEP11 SUBTRACT $TotalTime $STEP1 ECHO $TotalTime I tried that but, I got an error : Script run-time error in 'SO_STARWARSMOD_MAIN(B-5).TS': '13:22:51' is not a decimal number, line 139 So I know that my subtract command is my line 139 and that it's the problem of it's not a decimal number... So there is a command that I can use to count the time between the start time for my script ($STEP1) and my final time ($STEP11) ?? Each of my step is written in a Text file and give me the time of starting and ending of each step. But I would be able to have the total time of my running script without count it myself. Thanks you. It's my last problem with my big script that generate my SW edit. |
|
| Author: | Singularity [ Wed Jan 20, 2010 1:49 pm ] |
| Post subject: | Re: TIME AND TIMERS |
getTimer It's tick-based. Just divide by your avg ticks per second to derive seconds. getTime returns a standard notation, and while that works you do have to covert it to seconds past epoch before you can do anything. |
|
| Author: | Yop_Solo [ Wed Jan 20, 2010 1:52 pm ] |
| Post subject: | Re: TIME AND TIMERS |
Ok i will read on getTimer, i'm not familar on how to use it. If you have and example to help me, it will be nice to understand what you wrote to explain me. |
|
| Author: | Parrothead [ Wed Jan 20, 2010 4:16 pm ] |
| Post subject: | Re: TIME AND TIMERS |
Yop wrote: Hi to all TW scripters, I would like to generate a timer to know how long my script is running. Code: SETVAR $STEP1 TIME SETVAR $STEP11 TIME SETVAR $TotalTime $STEP11 SUBTRACT $TotalTime $STEP1 Code: gettime $first_time_stamp "h:n:s am/pm" replacetext $first_time_stamp ":" " " getword $first_time_stamp $hour0 1 getword $first_time_stamp $min0 2 getword $first_time_stamp $sec0 3 getword $first_time_stamp $stamp0 4 striptext $first_time_stamp "am" striptext $first_time_stamp "pm" #echo "*" $hour0 "*" $min0 "*" $sec0 "*" $stamp0 "*" setvar $first_total_second (($hour0*3600)+($min0*60)+$sec0) #run script here #setdelaytrigger one :one 5000 #pause #:one gettime $last_time_stamp "h:n:s am/pm" replacetext $last_time_stamp ":" " " getword $last_time_stamp $hour1 1 getword $last_time_stamp $min1 2 getword $last_time_stamp $sec1 3 getword $last_time_stamp $stamp1 4 striptext $last_time_stamp "am" striptext $last_time_stamp "pm" #echo "*" $hour1 "*" $min1 "*" $sec1 "*" $stamp1 "*" setvar $last_total_second (($hour1*3600)+($min1*60)+$sec1) setprecision 0 if ($stamp0 = $stamp1) setvar $script_run_time_sec ($last_total_second - $first_total_second) else setvar $script_run_time_sec (($last_total_second + 43200) - $first_total_second) end setprecision 1 setvar $script_run_hours ($script_run_time_sec/3600) if ($script_run_hours > 1) setvar $script_run_time_sec (($script_run_hours*3600)-$script_run_time_sec) end round $script_run_hours 0 setprecision 1 setvar $script_run_min ($script_run_time_sec/60) if ($script_run_min < 1) setvar $script_run_min 0 else setvar $script_run_time_sec (($script_run_min*60)-$script_run_time_sec) end round $script_run_min 0 setprecision 0 echo ANSI_14 "SCRIPT TOOK " $script_run_hours & " Hours " & $script_run_min & " Minutes " & $script_run_time_sec & " Seconds to run*" As long as you dont go past 12 hours run time this will work i think cela ne fait rien |
|
| Author: | ElderProphet [ Wed Jan 20, 2010 8:38 pm ] |
| Post subject: | Re: TIME AND TIMERS |
The best approach will depend on how long you expect the script to run. If it is something that is going to run for a few seconds, then getTimer will give very accurate results. If it will run for more than a few seconds, then you probably want to use getTime, and specify your own format. getTime takes formats based on Delphi's DateTimeToString command, so look up that command for more specifics. A few common formats might be: getTime $hour "h" getTime $minute "n" getTime $second "s" echo "*Duration: " ((($hour * 3600) + ($minute * 60)) + $second) " Seconds.*" Using this as a starting point, you should be able to manipulate and display the time lapse however you like. Good luck, +EP+ |
|
| Author: | General Disarray [ Tue Feb 23, 2010 2:50 pm ] |
| Post subject: | Re: TIME AND TIMERS |
Also, you can use the (undocumented) millisecond timer. "zzz" Code: getTime $starttime "s:zzz" striptext $starttime ":" getTime $endtime "s:zzz" striptext $endtime ":" setvar $pingtime (($endtime - $starttime) / 2) Useful if you want to compensate for lag. You would, of course have to add the rest of the ping script to get a real ping time, I included only the part that is undocumented, for the sake of clarity. My ping script is, I'm told very similar to ProPing, but having no source code for ProPing, I cannot say. |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|