lock statement

The lock statement sets one of 992 execution locks. 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

The following information applies to the lock statement:

  • If the specified lock is found unlocked, the lock statement performs the lock. If present, the then clause is executed.
  • If the lock is already locked by another process or by the current process at a different level, it remains locked.

    If present, the else clause is executed.

  • If the lock is locked by another process or by the current process at a different level, and no then or else clause is used, the program waits until the lock is unlocked.
  • If either a then clause or else clause (or both) is used, the lock statement will not cause the program to wait.

    It is assumed the programmer is doing what they need within the programming clauses.

Note: One beep character is printed if the lock statement waits.

Example(s)

Example 1

This example unconditionally sets execution lock 12.

 lock 12

Example 2

This example attempts to set lock 14.

If it is already locked, the program advises the operator and stops.

 lock 14 else crt "Program is locked" ; stop