The Alarm Clock Script
; Well one day I was travelling and the batteries in my travel alarm
; were dead and I needed an alarm clock...
;
; Then I got bored and the script got out of hand...
wave="OHNO.WAV"
while 1
now=TimeYmdHms()
dt=DateTime()
a=AskLine("Alarm %dt% (%now%)","Enter time to sound (0 to test)","7:30")
if a==0
BoxOpen("Alarm Sound Test","Press shift to stop")
while 1
PlayWaveForm(wave,0)
if IsKeyDown(@SHIFT) then break
endwhile
else
alarm=strcat("00:00:00:",a,":00")
test=TimeAdd(TimeYmdHms(),alarm) ; verify time is legit
now=TimeYmdHms()
trytime=strcat(strsub(now,1,9),a,":00")
x=TimeDiffSecs(trytime,now)
if x<0 then trytime=TimeAdd(trytime,"00:00:01:00:00:00")
BoxOpen("....","...")
while 1
rightnow=TimeYmdHms()
dt=DateTime()
BoxTitle("Current time %dt% (%rightnow%)")
timeleft=TimeDiffSecs(trytime,rightnow)
hleft=strfixLeft(timeleft/3600,"0",2)
mleft=strfixLeft((timeleft-(hleft*3600)) /60,"0",2)
sleft=strfixLeft(timeleft mod 60,"0",2)
showleft=strcat(hleft,":",mleft,":",sleft)
BoxText(strcat("Alarm Time %@tab%%trytime%",@crlf,@crlf,"Time Left %@tab%%showleft%"))
if TimeLeft<0 then break
TimeDelay(1)
endwhile
while 1
rightnow=TimeYmdHms()
dt=DateTime()
BoxTitle("Current time %dt% (%rightnow%)")
BoxText(strcat("Wake up",@crlf,@crlf,"Press and Hold SHIFT to stop."))
PlayWaveForm(wave,0)
if IsKeyDown(@SHIFT) then break
TimeDelay(5)
if IsKeyDown(@SHIFT) then break
endwhile
endif
endwhile
Article ID: W13859
Filename: Alarm Clock Script.txt