_FindVar( ) API Library Routine Example

The following example displays the value of a Visual FoxPro variable in a very roundabout way.

Visual FoxPro Code

SET LIBRARY TO FINDVAR 
TestVar= "This is a test"
= QMARK("TestVar")

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 NameTableIndexEx(ParamBlk FAR *parm)
{
   NTI nti;
   char FAR *name;
   Locator loc;
   Value val;

//   Null terminate character string, name of variable
   if (!_SetHandSize(parm->p[0].val.ev_handle, 
      parm->p[0].val.ev_length+1))
   {
      _Error(182); // "Insufficient memory"
   }
   _HLock(parm->p[0].val.ev_handle);
   name = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle);
   name[parm->p[0].val.ev_length] = '\0';

   nti = _NameTableIndex(name);

   _FindVar(nti, 0, &loc);
   _Load(&loc, &val);
   _PutValue(&val);
}

FoxInfo myFoxInfo[] = {
   {"QMARK", (FPFI) NameTableIndexEx, 1, "C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};