Skip to content

LOCK

Lock File for Exclusive Use

This directive prevents access to a file by all other users until it is removed by UNLOCK or CLOSEing the designated channel.

LOCK (channel [,ERR=line-ref|,ERC=error-code])
channel
is an integer in the range of 1 to 32764 that specifies the channel of an OPEN file. If omitted, the default is 0.
line-ref
is the program line number or label to branch to if this directive produces an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

This directive may only be used on a file that has already been OPENed and is not currently OPENed by any other task.

If an attempt is made to LOCK a file that is OPEN to another task, an ERR=0 results.

If an attempt is made to LOCK channel 0, an ERR=0 results.

The effect of this directive is removed by a BEGIN, CLOSE, END, STOP, or UNLOCK directive.

If an attempt is made to LOCK a terminal or device that is OPEN on a channel, an ERR=0 results. The OPEN directive on a terminal or device has the effect of LOCKing that terminal or device.

A SERIAL file must be LOCKed in order to WRITE data to it.

LOCK (1)

reserves the file OPEN on channel 1 for the exclusive use of this task.

LOCK (A, ERR=7999)

If A = 1, has the same effect as the first example and branches to statement 7999 if this directive produces an error condition.

01000 LOCK (1, ERR=01010); GOTO 01020
01010 IF ERR=0 THEN
GOTO 01000
ELSE
GOTO 08000
01020 REM "CONTINUE PROCESSING..."

attempts to LOCK the file OPEN on channel 1 and continues to try the LOCK until successful or some other error occurs, forcing a branch to 08000.

SERIAL and UNLOCK directives

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF