_EdGetChar( ) API Library Routine Example

The following example opens for editing a file specified by a parameter and displays on the screen the entire contents of the file.

Visual FoxPro Code

SET LIBRARY TO EDGETCHA
= EDGETCHAR("x")

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))

   WHANDLE wh;
   EDENV EdEnv;
   EDPOS edpos;

   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);
   pFILENAME[parm->p[0].val.ev_length] = '\0';
   wh = _EdOpenFile(pFILENAME, FO_READONLY);
   _HUnLock(parm->p[0].val.ev_handle);

   _EdGetEnv(wh, &EdEnv);

   for (edpos = 0; edpos <= EdEnv.length; edpos++)
   {
      _PutChr(_EdGetChar(wh, edpos));
   }
}

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