_EdSkipLines( ) API Library Routine Example

The following example opens for editing a file specified by a parameter. It uses _EdSkipLines( ) to find the offset positions, then selects lines 3 and 4.

Visual FoxPro Code

SET LIBRARY TO EDSKIPLI
= SKIPLINE("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;
   EDPOS edpos;

   if (!_SetHandSize(parm->p[0].val.ev_handle,
      parm->p[0].val.ev_length+1))
   {
      _Error(182); // "Insufficient memory"
   }
   pFILENAME[parm->p[0].val.ev_length] = '\0';

   _HLock(parm->p[0].val.ev_handle);
   wh = _EdOpenFile(pFILENAME, FO_READWRITE);
   _HUnLock(parm->p[0].val.ev_handle);

   // select next two lines
   edpos = _EdSkipLines(wh, 0, 2); // skip to two lines from top
   _EdSelect(wh, edpos, _EdSkipLines(wh, edpos, 2));
   _Execute("WAIT WINDOW 'Using _EdSkipLines() \
      to select lines 3 and 4'");
}

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