This function is used to ascertain the status of a record lock. It takes the general form:
filevar is a file variable from a previously executed OPEN statement.
recordkey is an expression for the record id that will be checked.
The function returns an integer value to indicate the record lock status of the specified record id.
||Locked by this process by a FILELOCK
||Locked by this process by a READU
||Locked by this process by a READL
||Locked by another process by a READL
||Locked by another process by a READU
||Locked by another process by a FILELOCK
If the return value is negative, then the SYSTEM(43) and STATUS function calls can be used to determine the port number of the program that holds the lock. If -1 is returned, more than 1 port could hold the lock and so the port number returned will be the first port number found.
An example of use is as:
OPEN "records" TO FILE_VAR ELSE ABORT "Cannot open records" IF(RECORDLOCKED(FILE_VAR, rec_key) = 0) THEN CRT "Record not locked" END
OPEN "INVENTORY" TO invFvar ELSE ABORT 201,"Cannot open the INVENTORY file" IF RECORDLOCKED (invFvar,invId) = -2 THEN CRT "Inventory record ":invId:" is locked by port ":SYSTEM(43) END
Go back to jBASE BASIC.