qbasic.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
TIMER, ON TIMER Statements
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
TIMER enables, disables, or suspends timer event trapping.
If event trapping is enabled, ON TIMER branches to a subroutine whenever
a specified number of seconds has elapsed.
 
TIMER ON
TIMER OFF
TIMER STOP
ON TIMER(n%) GOSUB line
 
    ■ TIMER ON      Enables timer event trapping.
    ■ TIMER OFF     Disables timer event trapping.
    ■ TIMER STOP    Suspends timer event trapping. Events are processed
                    once event trapping is enabled by TIMER ON.
    ■ n%            The number of seconds that elapse before ON TIMER
                    branches to the event-trapping subroutine; a value in
                    the range 1 through 86,400 (24 hours).
    ■ line          The label or number of the first line of the
                    event-trapping subroutine.
 
Example:
    ON TIMER(1) GOSUB TimeUpdate
    TIMER ON
    CLS
    PRINT "Time: "; TIME$
    StartTime = TIMER
    WHILE TimePast < 10
        TimePast = TIMER - StartTime
    WEND
    END
 
    TimeUpdate:
        LOCATE 1, 7: PRINT TIME$
        RETURN
 
See Also    TIMER Function