home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1B / DATAFILE_PDCD1B.iso / _pocketbk / pocketbook / 004 / aalarma_zi / AALARMA.OPL next >
Text File  |  1993-10-12  |  3KB  |  106 lines

  1. PROC aalarm:
  2.     global sndname$(6,9)
  3.     local r%,acb%,aactive%,astat%
  4.     local k%(2),kstat%,kactive%
  5.     local t1&,t2&,snd$(8)  rem keep together
  6.     local m$(20),ztsm$(22)
  7.     local dat&,tim&,atype%
  8.     local stype%
  9.     local warning&
  10.     initsns:
  11.     r%=ioopen(acb%,"ALM:",-1)
  12.     if r% :raise r% :endif
  13.     atype%=2
  14.     stype%=1
  15.     gBorder 4
  16.     busy "Any key sets alarm"
  17.     while 1
  18.         if kactive%=0
  19.             keya(kstat%,k%(1))
  20.             kactive%=1
  21.         endif
  22.         iowait
  23.         if aactive% and astat%<>-46
  24.             aactive%=0
  25.             giprint ""
  26.             busy "Any key sets alarm"
  27.             continue
  28.         endif
  29.         busy off
  30.         if k%(1)=27
  31.             giprint "Bye..."
  32.             pause -30
  33.             stop
  34.         endif
  35.         kactive%=0
  36.         if aactive%
  37.             iow(acb%,4,#0,#0)   rem cancel outstanding request
  38.             iowaitstat astat%
  39.             aactive%=0
  40.             dInit "Edit alarm"
  41.         else
  42.             t2&=timenow&:+3600
  43.             warning&=0
  44.             m$="Don't forget!"
  45.             dInit "Set alarm"
  46.         endif
  47.         dEdit m$,"Text message"
  48.         crack:(addr(t2&),addr(dat&),addr(tim&))
  49.         dDate dat&,"Date",days(day,month,year),days(31,12,2049)
  50.         dTime tim&,"Time",0,0,datetosecs(1970,1,1,23,59,59)
  51.         dLong warning&,"Advance time",0,10080
  52.         dChoice atype%,"Alarm type","Date only,Time and date"
  53.         dChoice stype%,"Sound","Rings,Chimes,Fanfare,Soft bells,Church bells,Silent"
  54.         if dialog
  55.             t2&=combine&:(addr(dat&),addr(tim&))
  56.             t1&=t2&-warning&*60
  57.             ztsm$=m$+chr$(0)
  58.             bufcopy:(addr(snd$)-1,addr(sndname$(stype%)),10)
  59.             ioa(acb%,atype%+9,astat%,t1&,#addr(ztsm$)+1)
  60.             aactive%=1
  61.             giprint "Alarm queued"
  62.             busy "Any key edits alarm"
  63.         else
  64.             busy "Any key sets alarm"
  65.         endif
  66.     endwh
  67. ENDP
  68.  
  69. PROC initsns:
  70.     sndname$(1)=chr$(1)
  71.     sndname$(2)=chr$(2)
  72.     sndname$(3)="SYS$AL01"
  73.     sndname$(4)="SYS$AL02"
  74.     sndname$(5)="SYS$AL03"
  75.     sndname$(6)=chr$(15)
  76. ENDP
  77.  
  78. PROC bufcopy:(di%,si%,cx%)
  79.     call($a1,0,cx%,0,si%,di%)   rem BufferCopy
  80. ENDP
  81.  
  82. PROC timenow&:
  83. REM returns LONG giving system time
  84.     local ax%,bx%,cx%,dx%,si%,di%,st&
  85.     ax%=$0200
  86.     os($89,addr(ax%))   rem TimGetSystemTime
  87.     pokew addr(st&),bx% :pokew addr(st&)+2,ax%
  88.     return(st&)
  89. ENDP
  90.  
  91. PROC crack:(ast%,adat%,atim%)
  92. REM cracks system time into day-sec format
  93.     local dat&,tim&
  94.     local cx%,dx%
  95.     cx%=peekw(ast%+2)
  96.     dx%=peekw(ast%)
  97.     call($0489,0,cx%,dx%,0,addr(dat&))  rem TimSystemTimeToDaySeconds
  98.     pokel adat%,dat&
  99.     pokel atim%,tim&
  100. ENDP
  101.  
  102. PROC combine&:(adat%,atim%)
  103. REM combines day-sec format into system time format
  104.     return(86400.0*(peekl(adat%)-25567.0)+peekl(atim%))
  105. ENDP
  106.