_FError( ) API Library Routine Example

The following example uses _FOpen( ) to attempt to open a file called Nofile.abc, which presumably doesn't exist. It then calls _FError( ), which returns error number 2, for "file not found."

Visual FoxPro Code

SET LIBRARY TO FERROR  

C Code

#include <pro_ext.h>

void putLong(long n)
{
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = 10;

   _PutValue(&val);
}

FAR Example(ParamBlk FAR *parm)
{
   FCHAN fchan = _FOpen("nofile.abc", FC_READONLY);
   _PutStr("\nAttempted to _FOpen() a file which does not exist.");
   _PutStr("\n_FError() ="); putLong(_FError());
}

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