_ErrorInfo( ) API Library Routine Example

The following example shows the information returned by _ErrorInfo( ).

Visual FoxPro Code

SET LIBRARY TO ERRORINF
= ERRORINFO(0)
= ERRORINFO(1)

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);
}

void FAR ErrorInfo(ParamBlk FAR *parm)
{
   int ext;
   char FAR *message;

   if ((message =_Alloca(128)) == 0)
   {
      _Error(182); // "Insufficient memory"
   }
   ext = _ErrorInfo((int) parm->p[0].val.ev_long, message);

   _PutChr('\n'); putLong(ext); _PutStr(" "); _PutStr(message);
}

FoxInfo myFoxInfo[] = {
   {"ERRORINFO", (FPFI) ErrorInfo, 1, "I"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};