time
来自「LastWave」· 代码 · 共 110 行
TXT
110 行
## The following works ONLY with delay/time binding # setproc _alarm {} { d = [time current] printf "Time is %d\n" d}# Be careful : time should be a gmt time !!binding delete 'alarm'setproc at {time} { y = [time current -d] u = [time 2sec {y[0] time}] setbinding 'alarm' terminal time u {_alarm} l = [binding info 'alarm'] if (l[0][1] == 0) {binding activate 'alarm'}}if ([msge Timers exist]) { msge Timers delete} window new 'Timers' -title "Timers" -pos 100 100 -size 500 300 msge Timers add 'n' Box -pos 10 30 -size 150 40 -font '20-bold'msge Timers showmsge Timers add 'b' Button -pos 200 30 -size 40 40 -fg 'black' -title 'Start' -handle '_stop' -behavior 'switch' -pen 2setproc _stop {obj state} { if (state == 0) { setgu Timers.b -title 'Start' binding deactivate 'clock' } else { setgu Timers.b -title 'Stop' binding activate 'clock' }}binding delete 'clock'setbinding 'clock' terminal delay .1 {_time}setbinding 'clock' Box delete { if (@objname == "Timers.n") { binding delete 'clock' }}__time = 0setproc _time {} { if (![msge Timers.n exist]) {return} global __time l = [time s2hms __time] sprintf s "%02d:%02d:%02d.%d" l[0] l[1] int(l[2]) int((l[2]-int(l[2]))*10) setgu Timers.n -string s __time += .1}_time msge Timers add 'n1' Box -pos 10 100 -size 150 40 -font '20-bold'binding delete 'clock1'setbinding 'clock1' terminal delay .1 {_time1}setbinding 'clock1' Box delete { if (@objname == "Timers.n1") { binding delete 'clock1' }}setproc _time1 {} { if (![msge Timers.n1 exist]) {return} l = [time current -l] sprintf s "%02d:%02d:%02d" l[0] l[1] l[2] setgu Timers.n1 -string s}_time1 binding activate 'clock1'msge Timers add 'b2' Button -pos 10 200 -size 150 40 -fg 'red' -handle '_stop2' -behavior 'switch' -pen 2 -font '20-bold'setproc _stop2 {obj state} { if (state == 0) { binding deactivate 'clock2' } else { binding activate 'clock2' }}binding delete 'clock2'setbinding 'clock2' terminal delay .1 {_time2}setbinding 'clock2' Button delete { if (@objname == "Timers.b2") { binding delete 'clock2' }}__time2 = 0setproc _time2 {} { if (![msge Timers.b2 exist]) {return} global __time2 l = [time s2hms __time2] sprintf s "%02d:%02d:%02d.%d" l[0] l[1] int(l[2]) int((l[2]-int(l[2]))*10) setgu Timers.b2 -title s __time2 += .1}_time2
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?