home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / utilsu / xopl1 / AALARM.OPL next >
Text File  |  1992-12-08  |  2KB  |  88 lines

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