QBasic 1.1: TIMER Statement
Explanation
TIMER, ON TIMER Statements
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.
Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Syntax
TIMER ON |
TIMER OFF |
TIMER STOP |
ON TIMER(n%) GOSUB line |
Description / Parameter(s)
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