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

  1. proc extpow:
  2.     global tcb%,tstat%,tint&
  3.     global kstat%,key%(2)
  4.     nonactv:
  5.     ioopen(tcb%,"TIM:",-1)
  6.     quetim:
  7.     quekey:
  8.     iosignal :rem force first iowait to return at once
  9.     do
  10.         iowait
  11.         if tstat%=0 :rem timer expired
  12.             quetim:
  13.         elseif kstat%=0 :rem keypress received
  14.             if key%(1)=27 :rem ESCAPE
  15.                 stop
  16.             elseif key%(1)>=%1 and key%(1)<=%9
  17.                 setauto:(60*(key%(1)-%0))
  18.             elseif key%(1)=%0
  19.                 setauto:(-1) :rem disable switch-off
  20.             endif
  21.             quekey:
  22.         endif
  23.         print right$(datim$,8),
  24.         print "Power:",getextp%:,
  25.         print "Auto off:",getauto%:
  26.     until 0
  27. endp
  28.  
  29. proc quetim:
  30.     tint&=100 :rem 10 seconds from now
  31.     ioa(tcb%,1,tstat%,#addr(tint&),#0) :rem P_FRELATIVE
  32. endp
  33.  
  34. proc quekey:
  35.     keya(kstat%,key%(1)) :rem queue keyboard read
  36. endp
  37.  
  38. proc nonactv:
  39. rem Don't keep the machine on just because of this app
  40.     call ($138b,0,0,0,0,0) :rem GenMarkNonActive
  41. endp
  42.  
  43. proc getextp%:
  44. rem returns 1 if mains present, else 0
  45.     local esup%(3),bx%
  46.     bx%=addr(esup%())
  47.     call ($118e,bx%,0,0,0,0) :rem HwGetSupplyStatus
  48.     return(esup%(3))
  49. endp
  50.     
  51. proc getauto%:
  52. rem returns auto-switch off time, in seconds
  53.     return call($178b,0,0,0,0,0) :rem GenGetAutoSwitchOffValue
  54. endp
  55.  
  56. proc setauto:(aut%)
  57. rem sets the auto-switch off time, in seconds
  58.     call($188b,aut%,0,0,0,0) :rem GetSetAutoSwitchOffValue
  59. endp
  60.