home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsr
/
teatime10
/
TEATIME.OPL
< prev
next >
Wrap
Text File
|
1994-11-08
|
4KB
|
279 lines
REM Teatime V 1.0 by Bernd Meyer
REM please report bugs and send comments to
REM bernd.meyer@fernuni-hagen.de
APP Teatime
Type 3
Path "\opd"
Ext "ttm"
Icon "\OPD\Teatime.pic"
ENDA
PROC main:
global handle%, a%(6), w$(128)
global dur&, ticks&, msg$(255), sel%, file$(128)
global stat%
local err%, key%
defaultwin 1
statuswin on,2
font 1,0
w$=cmd$(2)
fileh:(cmd$(3))
while 1
err%=ioopen(handle%,"ALM:",0)
if err%<0 : raise err% : exit: : endif
dinit "Teatime 1.0"
dtime dur&,"Duration",3,0,86399
dtime ticks&,"Ticks",3,0,43199
dedit msg$,"Message",20
dchoice sel%,"Sound","Fanfare,Soft Bells,Church Bells,Rings,Chimes,File,Silence"
dbuttons "Start",13,"Exit",-27
lock on
key%=dialog
lock off
if key%=0
dinit "Save Settings?"
dbuttons "Yes",%Y,"No",%N
lock on
if dialog=%y
save:
endif
lock off
exit:
elseif key%=13
if ticks&>=dur&
warning:("tick interval > duration","No ticks will be given")
ioclose(handle%)
continue
endif
if sel%=6
dinit "Select Soundfile"
dfile file$,"File",72
lock on
dialog
lock off
endif
if sel%=6 and not exist(file$)
warning:("cannot open file"," ")
ioclose(handle%)
continue
endif
count:
endif
gcls
ioclose(handle%)
endwh
ENDP
PROC count:
local expires&, dif&, hours%, minutes%, seconds%, lasttik&
local systime&, disp$(8), snd$(9)
local stat%, alm$(19), length%, offset%(6), key%, event%
expires&=dur&+datetosecs(year,month,day,hour,minute,second)
pokel addr(alm$),expires&
pokel uadd(addr(alm$),4), expires&
if sel%<=3
snd$="SYS$AL0"+gen$(sel%,1)
poke$ uadd(addr(alm$),8), snd$
endif
if sel%=4 or sel%=5
pokeb uadd(addr(alm$),8), 1
pokeb uadd(addr(alm$),9), sel%-3
endif
if sel%=6
parse$(file$,"",offset%())
snd$=mid$(file$,offset%(4),offset%(5)-offset%(4))
poke$ uadd(addr(alm$),8), snd$
endif
if sel%=7
pokeb uadd(addr(alm$),8), 1
pokeb uadd(addr(alm$),9), 16
endif
msg$=msg$+chr$(0)
ioc(handle%,11,stat%, alm$,#uadd(addr(msg$),1))
pbinit:
lasttik&=datetosecs(year,month,day,hour,minute,second)
do
systime&=datetosecs(year,month,day,hour,minute,second)
dif&=expires&-systime&
if ticks&<>0 and systime&-lasttik&>=ticks&
lasttik&=systime&
beep 5,300
endif
hours%=dif&/3600
minutes%=mod%:(dif&,3600)/60
seconds%=dif&-int(hours%)*3600-minutes%*60
disp$=num2str$:(hours%)+":"+num2str$:(minutes%)+":"+num2str$:(seconds%)
gat 160,55
gprintb disp$,100,3,0,0,5
gat 37,87
gfill 347*(1-flt(dif&)/dur&),16,0
event%=event%:
if event%=1
gfont $9a
gstyle 0
gat 180,128
gbutton "Esc",1,60,20,1
pause 5
gcls
dinit "Cancel Alarm?"
dbuttons "Cancel & Abort",-27, "Abort",32, "Resume",13
lock on
key%=dialog
lock off
if key%=0
iocancel(handle%)
iowaitstat stat%
break
elseif key%=32
break
elseif key%=13
pbinit:
endif
elseif event%=2
break
endif
until dif&<=0
ENDP
PROC pbinit:
gcls
ggrey 2
gborder 0
gfont $9a
gstyle 0
gat 180,128
gbutton "Esc",1,60,20,0
gfont 8
gstyle 9
gat 130,15
gxborder 1,3,160,55
gat 30,80
gxborder 1,3,360,30
ENDP
PROC save:
A.d&=dur&
A.t&=ticks&
A.m$=msg$
A.s%=sel%
A.f$=file$
if count=0
append
else
update
endif
giprint "Settings saved"
ENDP
PROC exit:
close
ioclose(handle%)
stop
ENDP
PROC mod%:(a&,b%)
RETURN a&-INT(a&/b%)*b%
ENDP
PROC num2str$:(num%)
local str$(2)
str$=gen$(num%,2)
if len(str$)=1 : str$="0"+str$ : endif
return str$
ENDP
PROC event%:
local t$(1)
if testevent
getevent a%()
if a%(1)=$404
w$=getcmd$
t$=left$(w$,1)
w$=mid$(w$,2,128)
if t$="X" or t$="C" or t$="O"
if t$="X"
save:
exit:
else
trap close
if err
raise err
endif
fileh:(t$)
endif
return 2
endif
elseif a%(1)=27
return 1
else
return 0
endif
endif
ENDP
PROC fileh:(t$)
if t$="C"
trap create w$,A,d&,t&,m$,s%,f$
elseif t$="O"
trap open w$,A,d&,t&,m$,s%,f$
endif
if err
cls : print err$(err)
get : exit:
endif
setname w$
if t$="C"
A.d&=210
A.t&=0
A.m$="Tea is ready"
A.s%=4
A.f$="loc::m:\wve\*.wve"
append
endif
dur&=A.d&
ticks&=A.t&
msg$=A.m$
sel%=A.s%
file$=A.f$
ENDP
PROC warning:(text1$,text2$)
dinit "Warning"
dtext "",text1$,2
dtext "",text2$,2
dbuttons "",13
lock on
dialog
lock off
ENDP