On count – Remote Processing CAMBASIC User Manual
Page 118

Comm ands - 85
ON COUNT
Tasking Statement
SYNTAX:
ON COUNT n GOS UB line/label
ON COUNT n G O S U B
PURPOSE:
To execute a subroutine when a preset count is reached.
REMARK S:
To use this statement you must first set up a counter with CONFIG COUN T and specify a preset
count.
Every time the preset count is reached, the counter is reset to zero and program flow br anches to the
routine specified by line. W hen the subroutine is finished, the progr am will resume execution.
If the line is not specified after the GOSU B, the function is disabled.
The param eter n is the counter number which ranges fr om 0 to 7.
See the Multitasking Chapter for more information.
RELATED:
C L E A R C O U N T , C O U N T , ST A R T C O U N T , ST O P C O U N T , R E SU M E C O U N T
EXAMPLE:
10 CONFIG PI0 0,1,1,1,1 : 'SET FOR INPUTS
20 CONFIG COUNT 0,0,0,500,AUTO
30 ON COUNT 0 GOSUB 60
35 START COUNT 0
40 '
50 GOTO 40
60 PRINT "limit reached"
70 RETURN
ERROR:
< Data negative> – for n
< Data out of range> – n > 7
< Can’t compile> – if line/label does not exist