FLock(), IsFLocked(), IsRLocked(), Sys(2011)
FLOCK() locks all records in a table, preventing any other user from obtaining a lock on the file. Records are still visible for others to view, browse and report on. SYS(2011) can be used to detect the status of the current record, without attempting to actually place a lock on the record. The Is?Locked() functions return a logical rather than SYS(2011)'s localizable string, for easier internationalization.
Usage |
lResult = FLOCK( [ nWorkArea | cAlias ] ) |
Parameter |
Value |
Meaning |
nWorkArea |
Integer |
Specifies the work area of the table to be locked. |
Omitted |
If cAlias is also omitted, the file lock is attempted in the current work area. |
|
cAlias |
Character |
Specifies the alias of the table to be locked. |
Omitted |
If nWorkArea is also omitted, the file lock is attempted in the current work area. |
|
lResult |
.T. |
The lock was placed successfully. |
.F. |
No lock was placed, either because others have locks on the table, or because there's no table open in the specified area or with the supplied alias. |
Example |
? FLOCK("Customer") |
Usage |
cReturn = SYS(2011) lLock = ISFLOCKED( [ nWorkArea | cAlias ] ) lLock = ISRLOCKED( [ nRecNo, [ nWorkArea | cAlias ] ]) |
Parameter |
Value |
Meaning |
cReturn |
"Exclusive" |
The current table is opened exclusively. |
"Record Unlocked" |
The current record is not locked by this workstation. |
|
"Record Locked" |
The current record is locked by this workstation. |
|
Empty String |
There is no table open in the current work area. |
|
nRecno |
Integer |
The record number whose lock is tested. |
lLock |
.T. |
The file or record is already locked. |
.F. |
The file or record is not locked, or, if you specified a work area, no table is open in that work area. |
Even more confusing, the IS functions return .F. if the work area you specify has no table open. If, on the other hand, you supply a bogus alias, you get the error "Alias not found." These functions should consistently do one or the other. |
Example |
? SYS(2011) lSafeToSave = ISEXCLUSIVE() OR ISFLOCKED() OR ISRLOCKED() |
See Also |
Begin Transaction, CursorSetProp(), IsExclusive(), Lock, Unlock |