Specifications

Commands - 83
ON TICK
Tasking Statement
SYNTAX: ON TICK n,t GOSUB line/label
ON TICK n,t GOSUB
PURPOSE: To cause periodic program branching.
REMARKS: This statement is used when periodic tasks must be executed. The GOSUB is executed every t
seconds.
There are three TICK timers in CAMBASIC. The parameter n ranges from 0-2. The TICK timers
are independent of each other.
The range of t is 0.005 to 327.68 seconds. The GOSUB branch occurs every t seconds unless the
second syntax is executed. Not specifying a line number or label after GOSUB disables the ON tick
subroutine.
Every t seconds an interval flag is set. At the conclusion of the current CAMBASIC command, a
GOSUB branch occurs.
See Multitasking Chapter for more information.
RELATED: CLEAR TICK, TICK
EXAMPLE: 10 ON TICK 1, 1 GOSUB 50
20 PRINT "*"
30 FOR X=0 TO 600:NEXT
40 GOTO 20
50 PRINT TICK(1)
60 RETURN
ERROR: <Data negative> – for t and n
<Data out of range> - if n > 2
<Time> 327.67 sec> - for t
<Can’t compile> – if line/label does not exist