Partager via


_DBStatus( ) API Library Routine

Returns status flags for the specified work area.

int _DBStatus(int workarea)
int workarea;               /* Work area. */

Remarks

If no table is open in the specified work area, _DBStatus( ) returns a negative integer whose absolute value is a Visual FoxPro error number. The following table shows returned status flags:

Flag Setting
DB_BOF Set under the same conditions as the Visual FoxPro function BOF( ).
DB_EOF Set under the same conditions as the Visual FoxPro function EOF( ).
DB_RLOCKED Set when the current record is locked, the table is locked, or the table is open exclusively.
DB_FLOCKED Set when the table is locked or the table is open exclusively.
DB_EXCLUSIVE Set when the table is open exclusively.
DB_READONLY Set when the table is open without write access.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example displays the status of the table open in the current work area. It checks each bit in the value returned by _DBStatus( ) and displays an appropriate message to the screen.

Visual FoxPro Code

SET LIBRARY TO DBSTATUS
= DBSTATUS()  && displays status of DBF in current work area

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   int dbstatus = _DBStatus(-1);
   _PutStr("\nStatus of DBF in current work area:");
   if (dbstatus & DB_BOF)
      _PutStr("\nBOF()");
   if (dbstatus & DB_EOF)
      _PutStr("\nEOF()");
   if (dbstatus & DB_RLOCKED)
      _PutStr("\nCurrent record is RLOCKed");
   if (dbstatus & DB_FLOCKED)
      _PutStr("\nDatabase is FLOCKed");
   if (dbstatus & DB_EXCLUSIVE)
      _PutStr("\nDatabase is open EXCLUSIVEly");
   if (dbstatus & DB_READONLY)
      _PutStr("\nDatabase is READONLY");
}

FoxInfo myFoxInfo[] = {
   {"DBSTATUS", (FPFI) Example, 0, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_DBLock( ) API Library Routine | _DBUnlock( ) API Library Routine | Accessing the Visual FoxPro API | BOF( ) Function | EOF( ) Function | ISRLOCKED( ) Function | ISFLOCKED( ) Function | ISEXCLUSIVE( ) Function | ISREADONLY( ) Function