Posted by member 37809 on 2004-04-17 23:52:22 link
"Fancy novelty chronograph".
Note:
I couldn't help but try to do 1/100 seconds. They're for novelty and appear incorrect (Toggle it quickly to see what I mean?) Either using litestep to do this doesn't produce the required precision/accuracy and/or my logic is off :D Those parts of the script are commented.
Tested under:
xlabellight-2.8.3
timer-0.5
mzscript-0.9-beta_12
.rc settings:
in a *mzVarFile:
in a *mzScriptFile:
[P.S. should this be in the Code forum or not?]
Note:
I couldn't help but try to do 1/100 seconds. They're for novelty and appear incorrect (Toggle it quickly to see what I mean?) Either using litestep to do this doesn't produce the required precision/accuracy and/or my logic is off :D Those parts of the script are commented.
Tested under:
xlabellight-2.8.3
timer-0.5
mzscript-0.9-beta_12
.rc settings:
; used to update our label
*Timer chronometer #l 1s !mchronometer_update
;*Timer chronometer #l 20 !mchronometer_update ; 20ms is overkill
; the label used to display the elapsed duration from the last reset
*Label chronometer
chronometerStartHidden false
chronometerUpdateInterval 999999
chronometerText "CHRONOGRAPH"
chronometerWidth 100
chronometerHeight 22
chronometerImage bar.png
chronometerAlign right
chronometerFont "Tahoma"
chronometerFontHeight 13
chronometerFontSmoothing true
chronometerRightBorder 5
chronometerFontColor 000000
chronometerOnLeftClick !mchronometer_toggle
chronometerOnLeftDoubleClick !mchronometer_toggle
chronometerOnMiddleClick !LabelClipboardCopy chronometer
chronometerOnMiddleDoubleClick !LabelClipboardCopy chronometer
chronometerOnRightClick !mchronometer_reset
chronometerOnRightDoubleClick !mchronometer_reset
; needed only to extract uptime information
*Label chronometerbackend
chronometerbackendStartHidden
chronometerbackendUpdateInterval 999999
chronometerbackendText "[uptime('d:h:n:s')]"
chronometerbackendWidth 1
chronometerbackendHeight 1
*Timer chronometer #l 1s !mchronometer_update
;*Timer chronometer #l 20 !mchronometer_update ; 20ms is overkill
; the label used to display the elapsed duration from the last reset
*Label chronometer
chronometerStartHidden false
chronometerUpdateInterval 999999
chronometerText "CHRONOGRAPH"
chronometerWidth 100
chronometerHeight 22
chronometerImage bar.png
chronometerAlign right
chronometerFont "Tahoma"
chronometerFontHeight 13
chronometerFontSmoothing true
chronometerRightBorder 5
chronometerFontColor 000000
chronometerOnLeftClick !mchronometer_toggle
chronometerOnLeftDoubleClick !mchronometer_toggle
chronometerOnMiddleClick !LabelClipboardCopy chronometer
chronometerOnMiddleDoubleClick !LabelClipboardCopy chronometer
chronometerOnRightClick !mchronometer_reset
chronometerOnRightDoubleClick !mchronometer_reset
; needed only to extract uptime information
*Label chronometerbackend
chronometerbackendStartHidden
chronometerbackendUpdateInterval 999999
chronometerbackendText "[uptime('d:h:n:s')]"
chronometerbackendWidth 1
chronometerbackendHeight 1
in a *mzVarFile:
; boolean: whether or not the chronometer is running
mchronometer_going 0
; number: the start time as your system uptime in number of seconds
mchronometer_starttime 0
; number: the number of seconds elapsed from the start time
mchronometer_duration 0
mchronometer_going 0
; number: the start time as your system uptime in number of seconds
mchronometer_starttime 0
; number: the number of seconds elapsed from the start time
mchronometer_duration 0
in a *mzScriptFile:
; needed because i don't have luck with !varmod
; c = a mod b
*script bang !mymod ;c a b
*script exec !varset mymodt %#%{\2}/%{\3}%#
*script exec !varset %{\1} %#%{\2}-%{mymodt}*%{\3}%#
*script exec !varremove mymodt
*script ~bang
; reset our duration to 0
*script bang !mchronometer_reset
*script exec !ifeval ("%{mchronometer_going}" = "1") '|TimerKill chronometer'
*script exec !mchronometer_set mchronometer_starttime
*script exec !varset mchronometer_duration 0
*script exec !LabelSetText chronometer "0’00”"
;*script exec !LabelSetText chronometer "0’00”00"
*script exec !ifeval ("%{mchronometer_going}" = "1") '|TimerStart chronometer'
*script ~bang
; update the text in our label with the current elapsed duration
*script bang !mchronometer_update
*script exec !mchronometer_set mchronometer_duration
*script exec !varadd mchronometer_duration "-%{mchronometer_starttime}"
*script exec !varset d %#%{mchronometer_duration}/86400%#
*script exec !mymod h %#%{mchronometer_duration}/3600%# 24
*script exec !mymod m %#%{mchronometer_duration}/60%# 60
*script exec !mymod s %{mchronometer_duration} 60
*script exec !ifeval ("10" > "%{s}") '|varset s "0%{s}"'
;*script exec !varset n %#%{milli}/10%#
;*script exec !ifeval ("10" > "%{n}") '|varset n "0%{n}"'
*script gotoif ("%{d}" > "0") d
*script gotoif ("%{h}" > "0") h
*script exec !LabelSetText chronometer "%{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{m}’%{s}”%{n}"
*script exit
*script label d
*script exec !LabelSetText chronometer "%{d}d %{h}h %{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{d}d %{h}h %{m}’%{s}”%{n}"
*script exit
*script label h
*script exec !LabelSetText chronometer "%{h}h %{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{h}h %{m}’%{s}”%{n}"
*script ~bang
; set varname to current system uptime in number of seconds
*script bang !mchronometer_set ;varname
*script exec !LabelUpdate chronometerbackend
*script exec !LabelmzscriptVarCopy chronometerbackend s
*script exec !varset d %{s:}
*script exec !varset s %{s:_}
*script exec !varset h %{s:}
*script exec !varset s %{s:_}
*script exec !varset m %{s:}
*script exec !varset %{\1} %#%{d}*86400+%{h}*3600+%{m}*60+%{s:_}%#
*script ~bang
; start or stop our chronometer
*script bang !mchronometer_toggle
*script gotoif ("%{mchronometer_going}" = "1") stop
*script exec !mchronometer_set mchronometer_starttime
*script exec !varadd mchronometer_starttime "-%{mchronometer_duration}"
*script exec !TimerStart chronometer
*script exec !varset mchronometer_going 1
*script exec !LabelSetFontColor chronometer 000000
*script goto rest
*script label stop
*script exec !TimerKill chronometer
*script exec !varset mchronometer_going 0
*script exec !LabelSetFontColor chronometer 7f7f7f
*script label rest
*script exec !mchronometer_update
*script ~bang
; restore the state of our chronometer at startup/recycle of litestep
*script bang !mchronometer_restore
*script gotoif ("%{mchronometer_going}" = "0") stopped
*script exec !mchronometer_set mchronometer_starttime
*script exec !varadd mchronometer_starttime "-%{mchronometer_duration}"
*script exec !TimerStart chronometer
*script goto rest
*script label stopped
*script exec !LabelSetFontColor chronometer 7f7f7f
*script label rest
*script exec !mchronometer_update
*script ~bang
*script start !mchronometer_restore
; c = a mod b
*script bang !mymod ;c a b
*script exec !varset mymodt %#%{\2}/%{\3}%#
*script exec !varset %{\1} %#%{\2}-%{mymodt}*%{\3}%#
*script exec !varremove mymodt
*script ~bang
; reset our duration to 0
*script bang !mchronometer_reset
*script exec !ifeval ("%{mchronometer_going}" = "1") '|TimerKill chronometer'
*script exec !mchronometer_set mchronometer_starttime
*script exec !varset mchronometer_duration 0
*script exec !LabelSetText chronometer "0’00”"
;*script exec !LabelSetText chronometer "0’00”00"
*script exec !ifeval ("%{mchronometer_going}" = "1") '|TimerStart chronometer'
*script ~bang
; update the text in our label with the current elapsed duration
*script bang !mchronometer_update
*script exec !mchronometer_set mchronometer_duration
*script exec !varadd mchronometer_duration "-%{mchronometer_starttime}"
*script exec !varset d %#%{mchronometer_duration}/86400%#
*script exec !mymod h %#%{mchronometer_duration}/3600%# 24
*script exec !mymod m %#%{mchronometer_duration}/60%# 60
*script exec !mymod s %{mchronometer_duration} 60
*script exec !ifeval ("10" > "%{s}") '|varset s "0%{s}"'
;*script exec !varset n %#%{milli}/10%#
;*script exec !ifeval ("10" > "%{n}") '|varset n "0%{n}"'
*script gotoif ("%{d}" > "0") d
*script gotoif ("%{h}" > "0") h
*script exec !LabelSetText chronometer "%{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{m}’%{s}”%{n}"
*script exit
*script label d
*script exec !LabelSetText chronometer "%{d}d %{h}h %{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{d}d %{h}h %{m}’%{s}”%{n}"
*script exit
*script label h
*script exec !LabelSetText chronometer "%{h}h %{m}’%{s}”"
;*script exec !LabelSetText chronometer "%{h}h %{m}’%{s}”%{n}"
*script ~bang
; set varname to current system uptime in number of seconds
*script bang !mchronometer_set ;varname
*script exec !LabelUpdate chronometerbackend
*script exec !LabelmzscriptVarCopy chronometerbackend s
*script exec !varset d %{s:}
*script exec !varset s %{s:_}
*script exec !varset h %{s:}
*script exec !varset s %{s:_}
*script exec !varset m %{s:}
*script exec !varset %{\1} %#%{d}*86400+%{h}*3600+%{m}*60+%{s:_}%#
*script ~bang
; start or stop our chronometer
*script bang !mchronometer_toggle
*script gotoif ("%{mchronometer_going}" = "1") stop
*script exec !mchronometer_set mchronometer_starttime
*script exec !varadd mchronometer_starttime "-%{mchronometer_duration}"
*script exec !TimerStart chronometer
*script exec !varset mchronometer_going 1
*script exec !LabelSetFontColor chronometer 000000
*script goto rest
*script label stop
*script exec !TimerKill chronometer
*script exec !varset mchronometer_going 0
*script exec !LabelSetFontColor chronometer 7f7f7f
*script label rest
*script exec !mchronometer_update
*script ~bang
; restore the state of our chronometer at startup/recycle of litestep
*script bang !mchronometer_restore
*script gotoif ("%{mchronometer_going}" = "0") stopped
*script exec !mchronometer_set mchronometer_starttime
*script exec !varadd mchronometer_starttime "-%{mchronometer_duration}"
*script exec !TimerStart chronometer
*script goto rest
*script label stopped
*script exec !LabelSetFontColor chronometer 7f7f7f
*script label rest
*script exec !mchronometer_update
*script ~bang
*script start !mchronometer_restore
[P.S. should this be in the Code forum or not?]