home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / oplexamp / ABSTIM.OPL < prev    next >
Text File  |  1992-04-08  |  1KB  |  66 lines

  1. proc abstim:
  2. rem Demonstrates absolute timers
  3. rem and spawning another Opl program
  4.     global tcb%,tstat%,tint%
  5.     global kstat%,key%(2)
  6.     ioopen(tcb%,"TIM:",-1)
  7.     settint:(1) :rem wakes up once every ten minutes
  8.     quekey:
  9.     do
  10.         quetim:
  11.         iowait
  12.         if kstat%=0 :rem keypress received
  13.             if key%(1)=27 :rem ESCAPE
  14.                 stop
  15.             elseif key%(1)>=%1 and key%(1)<=%9
  16.                 settint:(key%(1)-%0)
  17.                 cantim:
  18.             quekey:
  19.             endif
  20.         elseif tstat%=0 :rem timer expired
  21.             runext:
  22.         endif
  23.     until 0
  24. endp
  25.  
  26. proc settint:(m%)
  27. rem Set value of tint% and report to user
  28.     tint%=10*m%
  29.     print "Will run extpow once every",tint%,"minutes"
  30. endp
  31.  
  32. proc quetim:
  33.     local s&
  34.     s&=datetosecs(year,month,day,hour,minute,second)
  35.     s&=(1+s&/(tint%*60))*(tint%*60)
  36.     while ioa(tcb%,2,tstat%,#addr(s&),#0)<0
  37.         s&=s&+tint%*60
  38.     endwh
  39. endp
  40.  
  41. proc cantim:
  42. rem Cancel timer
  43.     iow(tcb%,4,#0,#0) :rem P_FCANCEL
  44.     iowaitstat tstat%
  45. endp
  46.  
  47. proc quekey:
  48.     keya(kstat%,key%(1)) :rem queue keyboard read
  49. endp
  50.  
  51. proc runext:
  52. rem Starts a copy of extpow running
  53.     local pid%
  54.     local cmdl$(128),appname$(128)
  55.     local ret%
  56.     appname$="ROM::SYS$PRGO"+chr$(0)
  57.     cmdl$="ORunOpl"+chr$(0)+chr$(0)+"LOC::M:\OPO\EXTPOW.OPO"+chr$(0)
  58.     ret%=call($0187,addr(appname$)+1,addr(cmdl$),0,0,addr(pid%))
  59.     if ret%<0
  60.         print(err$(ret%))
  61.     else
  62.         call($0688,pid%,0,0,0,0) :rem ProcResume
  63.     endif
  64. endp
  65.     
  66.