lock statement

The lock statement sets one of 992 execution locks, in the range from 0 through 63. This prevents re-entry to the program, allowing only one process to run the program at any given time.

Syntax

lock lock.num{then|else statement.block}

Parameter(s)

lock.num Specifies the line number (from 0 to 991) to lock. If lock.num is greater than 991, the result is divided by 992, and the lock number is equal to the remainder of the equation.

Description

If the specified lock is found unlocked, this statement performs the lock and the then clause, if present, is executed. If the lock is already locked by another process or by the current process at a different level, it remains locked and the else clause, if present, is executed. If the lock is locked by another process or by the current process at a different level and no else clause is used, the program waits until the lock is unlocked.

Example(s)

This unconditionally sets execution lock 12.

lock 12

Attempts to set lock 14. If already locked, the program advises the operator and stops.

lock 14 else crt "Program is locked" ; stop