Specifications

Commands - 68
LOCK and UNLOCK
Tasking Statements
SYNTAX: LOCK
UNLOCK [RETURN]
PURPOSE: To lock out interrupts from time critical portions of a program.
REMARKS: When an interrupt occurs from a ON TICK, ON COM$, etc., the current program is interrupted and
the interrupt subroutine is called.
In some cases, especially where time is critical, it is desirable that the current program not be
interrupted until it is completed. When the command LOCK is executed, any interrupts will be
latched, but not executed until the UNLOCK command is executed.
The UNLOCK RETURN is only used at the end of a GOSUB routine. In this case a previous LOCK
must occur in the subroutine. For these commands to prevent any part of a subroutine from being
interrupted, LOCK must be the first line of the subroutine. Therefore, the GOSUB must use a line
number, not a label.
EXAMPLE: 10 GOSUB 500
20 IF PRESSURE > 234 THEN ALARM = 1.
.
500 LOCK
510 PRESSURE = AIN(6) - AIN(0)
520 UNLOCK RETURN
If this construct were not used, an interrupt could occur between lines 500 and 510 and/or between
lines 510 and 520 and delay the alarm flag being set in line 20.
ERROR: none