HTBasic Help
×
Menu
Index

LOCK

Secures a file for exclusive access.
 
 LOCK @io-path; CONDITIONAL return
 
Usage:
LOCK @Proprietary;CONDITIONAL Result
IF Secure THEN LOCK @Keyfile;CONDITIONAL Ok
 
Example:           LOCK.BAS
 
Description:
This command attempts to LOCK a file to prevent other users from accessing the file while you are using it. The return value is zero if the file is successfully LOCKed and non-zero if the LOCK fails. The value returned is an error number, indicating why the LOCK failed. An ASSIGN @Path TO * will UNLOCK and then close the file.
 
File locking capabilities depend on the operating system HTBasic is running on. If the operating system does not support it, the result value will always indicate failure. Some operating systems require the LOCK request when the file is opened. On such a system, the file will be closed and re-opened with the LOCK.
A file can have multiple locks on it. The file remains locked until a corresponding number of UNLOCK statements have been executed. LOCKing a file should be a temporary action of short duration so that fair access to the file is provided to all network users.
 
See Also: