filelock Statement

The filelock statement sets an exclusive lock on an entire file.

Syntax

filelock {file.var} {locked statement.block}

Parameter(s)

file.var

File to lock. If file.var is not specified, then the default file variable is assumed.

locked statement.block  

If the file is already locked (meaning another user has a file or an item lock, or is currently updating that file) and the optional locked clause is present, then statement.block is executed. If no locked clause is present, then the statement blocks until the situation is resolved.

NOTE— system(0) in the locked clause returns the port number that has the item locked.

Description

The filelock statement is useful for preventing updates to a file while a sequential operation is running (like a BASIC select).

NOTE

For Windows: The filelock statement is supported only for VME files. It is not supported for FSI files.

Once a file lock has been set, any attempt by another port to update, item lock, or file lock that file fails.

File locks are displayed by the TCL list-locks command as special item locks with item-IDs of * and hash values of 0. If necessary, these locks can be cleared atypically with the TCL unlock-file command.

CAUTION

The filelock statement sets broad locks that can severely impact other users. Developers should plan carefully when using this facility.

See Also

begin work Statement, clear-basic-locks Macro, clear-locks Command, fileunlock Statement, list-locks Command, Statement Blocks, Statements and Functions, then Clause, then/else Statement Blocks, u0191 User Exit, u1191 User Exit, u2191 User Exit, u3191 User Exit, unlock Statement, unlock-file Command, unlock-item Command