# LOCK

Updated: 11/30/2021, 7:00:45 PM
Created: 11/30/2021, 7:00:45 PM
Last Updated By: Jake Tuttle
Read Time: 1 minute(s)

Tags: program execution

# Description

The LOCK statement will attempt to set an execution lock thus preventing any other program that respects that lock to wait until this program has released it. It takes the general form:

LOCK expression {THEN|ELSE statements}
1

Where :

  • expression should evaluate to a numeric value between 0 and 255 (63 in R83, AP or D3 emulations),
  • statements will execute the THEN clause (if defined) providing the lock could be taken. If another program holds the LOCK and an ELSE clause is provided then the statements defined by the ELSE clause are executed. If no ELSE clause was provided with the statements then it will block (hang) until the other program has released the lock.

If the environment variable JBCEMULATE is set to R83, AP or D3, to compile the program the number of execution locks is limited to 64. If an execution lock greater than this number is specified, the actual lock taken is the specified number modulo 64.

LOCK 32 ELSE
    CRT "This program is already executing!"
    STOP
END
1
2
3
4

Locks are retained in memory only and will not persist if the server or jBASE service is restarted.

See also: UNLOCK.

Go back to jBASE BASIC

Go back to Programmers' Reference Guide