_DBUnlock( ) API Library Routine

JavaScript Editor js editor     Web development 



Main Page

Releases all user-obtained locks on records or the file in the work area specified by workarea.

void _DBUnlock(int workarea)
int workarea;               /* Work area. */

Example

The following example uses _DBUnlock(В ) to unlock all records of the table open in the current work area. The Visual FoxPro code demonstrates _DBUnlock(В ) and verifies that it's working properly.

Visual FoxPro Code

В Copy Code
SET LIBRARY TO DBUNLOCK
DO CreateTest
USE Test SHARED
GO 2
= XRLOCK()
LIST STAT  && shows that record #2 is locked
= XUNLOCK()
LIST STAT  && shows no records are locked
= XFLOCK()
LIST STAT  && shows that whole DBF is locked
= XUNLOCK()
LIST STAT  && shows no records are locked

PROCEDURE CreateTest

CREATE TABLE test (ABC C(20))
APPEND BLANK
REPLACE ABC WITH "Golly month of"
APPEND BLANK
REPLACE ABC WITH "A twelfth of"
APPEND BLANK
REPLACE ABC WITH "Hello, world"
APPEND BLANK
REPLACE ABC WITH "When in the"
GO TOP

RETURN

C Code

В Copy Code
#include <pro_ext.h>

FAR xLockRecord(ParamBlk FAR *parm)
{
   _DBLock(-1, DBL_RECORD);
}
FAR xLockFile(ParamBlk FAR *parm)
{
   _DBLock(-1, DBL_FILE);
}
FAR xUnLockFile(ParamBlk FAR *parm)
{
   _DBUnLock(-1);
}
FoxInfo myFoxInfo[] = {
   {"XRLOCK",  (FPFI) xLockRecord, 0, ""},
   {"XFLOCK",  (FPFI) xLockFile, 0, ""},
   {"XUNLOCK", (FPFI) xUnLockFile, 0, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also



JavaScript Editor js editor     Web development