<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods > Locked |
Declaration
function Locked( lRecNum: LongInt ): WordBool;
Description
Determines the lock status of a record or a file.
On a peer-to-peer network (such as Windows NT), you must set OptimisticBuffer to False. Otherwise, RLock will always return True and Locked will always return False. This is because with Optimistic Buffering enabled, no locks are actually applied. RLock still returns True because there is no reson to deny access to the record in that mode. On dedicated server networks (such as Novell Netware) Optimistic Buffering is turned off automatically by default.
Parameters
lRecNum: If you wish to determine whether a record is locked, pass the record number (from RecNo) in lRecNum. If you want to find out if the file is locked, pass lRecNum as zero (0).
Return Value
True if the record or file is locked, and False if not.
Delphi Examples
// Check lock status of current record
if ApTbl.Locked( ApTbl.RecNo ) then
ShowMessage( 'This record currently locked by another user.' );
...
// Check lock status of file before capturing
if ApTbl.Locked( 0 ) then
ShowMessage( 'File is in use. Try again later' );
else
begin
if ApTbl.Flock then
begin
ApTbl.Pack;
ApTbl.Unlock( ApTbl.RecNo );
end
else
ShowMessage( 'Lock failure' );
end;
...
C++Builder Example
// Check lock status of file before capturing
if (ApTbl->Locked( 0 ))
ShowMessage( "File is in use. Try again later" );
else
{
if (ApTbl->Flock())
{
ApTbl->Pack();
ApTbl->Unlock( ApTbl->RecNo );
}
else
ShowMessage( "Lock failure" );
}
See Also