a basic Chronometer using milliseconds, seconds and minutes
i didnt find anything like this here, so i create this one
if you find any bug report it
• copy and paste it into a new remote page alt+r
• right click in a channel or status, then click on Chronometer
you can start, stop, pause, and unpause the chronometer
alias chrom_timer {
set %mime $ticks
.timerchrom -h 0 1 chrom_count
}
alias chrom_count {
if ($calc($ticks - %mime) >= 999) {
.timerchrom off | inc %mime2 1 | $iif($dialog(chrom), did -ar chrom 1 %mime2) | chrom_timer
}
if (%mime2 == 60) && ($calc($ticks - %mime) > 0) {
unset %mime2
did -r chrom 4 | inc %mime2 1 | inc %mime3 1 | $iif($dialog(chrom), did -ar chrom 7 %mime3)
}
if (%mime3 == 60) && ($calc($ticks - %mime) > 0) {
unset %mime* | did -r chrom 1,4,7 | chrom_timer
}
else { did -ar chrom 4 $calc($ticks - %mime) }
}
dialog chrom {
title "Chronometer"
size -1 -1 144 73
option dbu
edit "", 1, 57 26 24 10, disable right
button "Start", 2, 28 40 37 12
button "Stop", 3, 28 40 37 12
edit "", 4, 85 26 28 10, disable right
text "Seconds", 5, 57 17 25 8
text "Milliseconds", 6, 85 17 30 8
edit "", 7, 27 26 26 10, disable right
text "Minutes", 8, 27 17 25 8
button "Pause", 9, 73 40 37 12
text "", 10, 13 58 121 8
button "Unpause", 11, 73 40 37 12
}
menu channel,status {
.Chronometer:{
dialog $iif($dialog(chrom), -v, -m chrom) chrom
}
}
on *:dialog:chrom:init:*:{
did -h chrom 3
did -ar chrom 1,4,7 0
did -bh chrom 9,11
}
on *:dialog:chrom:sclick:*:{
if ($did == 2) { did -r chrom 1,4,10 | did -h chrom 2 | did -v chrom 3,9 | chrom_timer | did -ar chrom 7 0 | did -e chrom 9,11 }
if ($did == 3) { did -h chrom 3 | did -v chrom 2 | .timerchrom off | unset %mime* | did -ar chrom 10 Elapsed time: $did(7).text min(s) $did(1).text sec(s) $did(4).text millisecond(s) | did -r chrom 1,4,7 | did -b chrom 9,11 }
if ($did == 9) { .timerchrom -p | did -h chrom 9 | did -v chrom 11 }
if ($did == 11) { .timerchrom -r | did -h chrom 11 | did -v chrom 9 }
}
on *:dialog:chrom:close:*:{
.timerchrom off
unset %mime*
}
I see. But doing the IF check at the beginning of alias chrom_count like I showed above would still do a catch-all, would it not? Since chrom_count is ONLY called by the timer, if the timer were to fault out chrom_count would no longer be called and the dialog would go dead (assuming it had not faulted out).
Gummo: If that is the case, shouldn't it be that way on all of the IF/ELSE statements? The third IF statement and the ELSE statement do not make these checks.
if (!$dialog(chrom)) { .timerchrom off | return }
You could just have this at the beginning, and it will not only keep from flooding, but it would turn off the timer that would otherwise continue running, since a high-res timer would be pointless to keep running when it consumes computer resources.
IllogicTC, should the dialog somehow manage to close without unsetting the timer due to some error, you would be flooded by errors at what should be once every millisecond, though it probably would be much less.
Even so, I'm fine with the check to make sure that the dialog is open within a command called by a timer.