EPOC   SDK Home Glossary   Previous Next Up

Timer — Countdown timer

    REM Include System.oxh, which declares System.opx and
    REM supplies the MOD&: (modulo) function:
    INCLUDE "System.oxh"
    PROC timer:
          LOCAL min&,sec&,secs&,i%
          sec&=1
          dINIT "Countdown timer"
          dLONG min&,"Minutes",0,59
          dLONG sec&,"Seconds",0,59
          dBUTTONS "Cancel",-27,"Start",%s
          IF DIALOG=%s
                FONT 12,16
                secs&=sec&+60*min&
                WHILE secs&
                      PAUSE -20                     REM a key gets us out
                      IF KEY
                            RETURN
                      ENDIF
                      secs&=secs&-1
                      AT 20,6 :PRINT NUM$(secs&/60,-2);"m"
                      AT 24,6 :PRINT NUM$(mod&:(secs&,int(60)),-2);"s"
                ENDWH
                DO
                      BEEP 5,300
                      PAUSE 10      
                      IF KEY :BREAK :ENDIF
                      i%=i%+1
                UNTIL i%=10
          ENDIF
    ENDP
EPOC       SDK Home Glossary   Previous Next Up