This little dialog is a clock that is the same time as the clock on your computer. It has 12 hour and 24 hour options. The title of the dialog will be the current date. The dialog will also reset at midnight so the title will change to the correct day.
The first time you open the dialog it will be on the 12 hour time. If you choose the 24 hour time it will set a variable and then if you close and reopen the dialog it will open and be on the 24 hour time setting. Same goes if you choose the 12 hour setting.
http://i22.photobucket.com/albums/b328/scakk/ClockDialog.jpg <-- 24 hour version
Update: Changed the 12h to 1 "h" instead of 2 "h". Change the 24h to be without the AM/PM part. Added " $chr(32) $+ $chr(32) $+ " to the title line to make the date centered on the dialog title.
menu channel {
Clock: clock
}
dialog clock {
title Clock
size -1 -1 165 30
edit "", 1, 40 6 85 20, read flat center
button "12H", 2, 5 5 30 22
button "24H", 3, 130 5 30 22
}
on *:dialog:clock:*:*: {
if ($devent == init) {
dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy)
$iif((%clocktime24), clock.update2, clock.update1)
$iif((%clocktime24), .timertcd2 0 1 clock.update2, .timertcd1 0 1 clock.update1)
}
if ($devent == close) { .timerclock off | .timertcd* off }
if ($devent == sclick) {
if ($did == 2) { .timertcd2 off | .timertcd1 0 1 clock.update1 | set %clocktime12 on | unset %clocktime24 }
if ($did == 3) { .timertcd1 off | .timertcd2 0 1 clock.update2 | set %clocktime24 on | unset %clocktime12 }
}
}
alias clock.update1 { did -ra clock 1 $time(h:nn:ss TT) | dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy) }
alias clock.update2 { did -ra clock 1 $time(HH:nn:ss) | dialog -t clock $chr(32) $+ $chr(32) $+ $date(ddd mmm doo 'yy) }
alias clock { dialog $iif($dialog(clock), -va, -m) clock clock }