_EdScrollToSel( ) API Library Routine Example
The following example opens for editing a file specified by a parameter. The example makes a selection near the bottom of the file. After the user presses a key in response to a Visual FoxPro WAIT command, the example scrolls the editing window to the selection by calling _EdScrollToSel( ). The example then repeats the operation for a selection made near the top of the file.
SET LIBRARY TO EDSCTOSE
= TOSEL("x")
#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)
{
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))
   WHANDLE wh;
   EDENV EdEnv;
   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_READONLY);
   _HUnLock(parm->p[0].val.ev_handle);
   _EdScrollToPos(wh, 0, TRUE);
   _EdGetEnv(wh, &EdEnv);
   _EdSelect(wh, EdEnv.length - 16, EdEnv.length);
   _PutStr("\nMade selection at end of file.");
   _Execute("WAIT WINDOW 'Press any key to scroll to selection.'");
   _EdScrollToSel(wh, TRUE);
   _EdSelect(wh, 1, 16);
   _PutStr("\nMade selection at beginning of file.");
   _Execute("WAIT WINDOW 'Press any key to scroll to selection.'");
   _EdScrollToSel(wh, TRUE);
}
FoxInfo myFoxInfo[] = {
   {"TOSEL", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};