Attempts to lock the current or specified table.
Syntax
FLOCK([nWorkArea | cTableAlias])
Returns
Logical
Arguments
nWorkArea
Specifies the work area of the table that FLOCK( ) attempts to lock.
FLOCK( ) returns false (.F.) if a table isn't open in the work area you specify.
cTableAlias
Specifies the alias of the table that FLOCK( ) attempts to lock.
Microsoft Visual FoxPro generates an error message if you specify a table alias that doesn't exist.
Remarks
FLOCK( ) returns true (.T.) if the table is successfully locked and returns false (.F.) if the table or a record in the table is already locked by another user.
If you omit the optional arguments, FLOCK( ) attempts to lock the table open in the currently selected work area.
Note If FLOCK( ) fails to lock a table, it returns false (.F.) and does not generate an error. As a result, you can't use FLOCK( ) to trigger an ON ERROR routine.
When a table is locked, the table is available for both read and write access by the user who placed the lock. Other users on the network have read-only access to the table. For information on how to lock a table and prevent access to it by other users, see SET EXCLUSIVE and USE.
A table remains locked until it is unlocked by the user who placed the lock. The table can be unlocked by issuing UNLOCK, closing the table, or quitting Visual FoxPro. Tables can be closed with USE, CLEAR ALL, or CLOSE DATABASES.
By default, FLOCK( ) attempts to lock a table once. Use SET REPROCESS to automatically retry a table lock when the first attempt fails. SET REPROCESS determines the number of lock attempts, or the length of time during which lock attempts are made when the initial lock attempt is unsuccessful. For more information, see SET REPROCESS.
You can establish relations between two or more tables with SET RELATION. Placing a file lock on a table that is related to one or more tables doesn't place a file lock on the related tables. You must explicitly place and remove locks on the related tables.
For additional information about record and file locking and sharing tables on a network, see Chapter 17, "Programming for Shared Access," in the Programmer's Guide.
For additional information about record and file locking and sharing tables on a network, see Chapter 17, Programming for Shared Access, in the Programmer's Guide.