_DBStatus( ) API Library Routine 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
};