Function FLock() Foundation
Locks a database file opened as SHARED for write access.
FLock() --> lSuccess
The return value of FLock() is .T. (true) if the database file was locked for SHARED write access. Otherwise .F. (false) is returned.
The database function FLock() locks an open database file for write access preventing write access from other work stations. This is required for a multi-user application in a network environment when a user is executing file operations on a file which could be in use by other users at the same time. When the file could be locked, FLock() returns the value .T. (true). The file is then available to other users only for read access until the file lock is released with DbUnlock(), RLock() or a command like UNLOCK or CLOSE.
A file must be locked with FLock() when file operations that change more than one record are executed. Commands like INDEX ON or UPDATE ON which affect all records of a file belong to this group. Also, when more than one record will be changed by RECALL, DELETE or REPLACE, a file lock must be set in a multi-user application. The effect of FLock() is equivalent to a USE command with the option EXCLUSIVE specified.
Each call to FLock() attempts to lock the file in a work area only once. When the function is used without the alias operator, the attempt to lock the file occurs in the current work area. When the file was locked, FLock() returns the value .T. (true). The file then remains locked to other users until the file lock is released. Other users have only read access to the file after a successful lock.
When relations are defined for the specified file using SET RELATION or DbRelation(), dependent files may also need to be locked. Automatic locking of all dependent files does not occur using FLock().
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.