| LOCATE | Index Level | LOCKED |
| Syntax | LOCK lock.number {THEN | ELSE statement.block} |
| Category | BASIC |
| Type | Statement |
| Description |
sets one of 64 "execution" locks, in the range 0 to 63. This prevents program "re-entrancy", allowing only one process to run the program at any given time.
If the specified lock is found "unlocked", this statement "locks" 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. If the "lock.number" expression evaluates to greater than 63, the result is divided by 64, and the "lock.number" is equal to the remainder of the equation. See the "then/else construct" for an explanation on the use of "then" and "else" clauses in statements that allow or require them. |
| Options | |
| See Also | statements & functions UNLOCK unlock-item THEN | ELSE statement.block THEN statement.block clear-basic-locks clear-locks u0191 u2191 u1191 u3191 list-locks (R83) unlock-file |
| Example |
lock 12
This unconditionally sets execution lock 12. lock 14 else crt "Program is locked" ; stop This attempts to set lock 14. If it is already locked, the program advises the operator and stops. |
| Warnings | |
| Compatibility | D3 7.0 R83 AP |
| LOCATE | Index Level | LOCKED |