User`s guide

50
CipherLab BASIC Compiler
User's Guide
ON TIMER ... GOSUB ...
Purpose
To activate the "TIMER Event Trigger" that executes a specific subroutine when
the system runs out of the time duration specified by the user.
Syntax
ON TIMER(N%, duration%) GOSUB SubName|SubLabel
Remarks
"N%" is an integer variable in the range of 1 to 5, indicating the ordinal number of
timer.
"duration%" is an integer variable, indicating a specified period of time in units of
10 ms.
"SubName|SubLabel" is the name or line label of a subroutine to be called when the
event is triggered.
Up to five timers can be set in a BASIC program. Be sure the timer IDs are
different. Otherwise, the latter created timer will overwrite the former one.
Example
ON TIMER(1, 200) GOSUB ClearScreen
...
ClearScreen:
OFF TIMER(1)
CLS
RETURN
' TIMER(1) = 2 sec
See Also
Calendar & Timer commands, OFF TIMER
5.5.2 Lock and Unlock
Event trapping could be nested. If the event triggers are activated in a BASIC program, it is
possible that an event-driven subroutine can be interrupted by any upcoming events.
Normally, the new event would be processed first. In some cases where we don’t want the
event-driven subroutine to be interrupted by other events, the LOCK and UNLOCK
commands can be used to hold off new events.
LOCK
Purpose
To hold all the activated event triggers until they are released by the UNLOCK
command.
Syntax
LOCK
Remarks
Command LOCK can prevent the nesting of event triggers. All the activated event
triggers will be disabled until UNLOCK is called.