Chapter
10
I
BASIC Keywords
ON
TIMER()
GOSUB
Statement
ON
TIMER(number1
GOSUB
line
Transfers program control
to
a
subroutine when the specified pe-
riod of time has elapsed.
Number
indicates the number
of
seconds.
Number
may be a
value in the range
1
to
86400 (86400 seconds
=
24 hours).
Line
is the
first
line number in the subroutine
to
execute when
the specified time has passed.
If
you specify Line 0, you turn off
trapping
for
the timer. Use RETURN
to
exit the subroutine.
BASIC executes the
ON
TIMER0 GOSUB statement only
if
a
TIMER
ON
statement has been executed previously
to
enable
time event trapping.
If a TIMER STOP statement has been issued
to
halt time event
trapping temporarily, BASIC executes the subroutine immedi-
ately after the next TIMER
ON
statement.
When you execute the ON TIMER() GOSUB statement, BASIC
immediately issues a TIMER STOP
to
prevent recursive traps.
When BASIC executes the RETURN from the subroutine, it au-
tomatically executes another TIMER ON statement
to
enable
trapping again, unless the subroutine executes a TIMER
OFF
statement.
240