
Commands - 75
LOCK
UNLOCK
Tasking Statements
SYNTAX: LOCK
UNLOCK [RETURN]
UNLOCK E XIT
PURPOSE: To lock out interrupts from time critical portions of a program.
REMARK S: 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. W hen the command LO CK is executed, any interr upts will be
latched, but not executed until the UNLOCK command is executed.
The UNLOC K RETU RN 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, LO CK must be the first line of the subroutine. Therefore, the GOSUB must use a
line number, not a label.
UNLOCK EXIT may be used to quickly get out of a FOR-NEXT, GOSUB, or other nested routine.
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
Commenti su questo manuale