_EdGetStr( ) API Library Routine

Places the text between and including the specified offset positions into the specified address.

void _EdGetStr(WHANDLE wh, EDPOS thePos, EDPOS thePos, 
               TEXT *theStr)
WHANDLE wh;            /* Handle of editing window. */
EDPOS thePos;               /* Starting offset position. */
EDPOS thePos;               /* Stopping offset position. */
TEXT *theStr;               /* Where to put the text. */

Example

The following example takes a file name as a parameter and returns the first 16 bytes of the file.

Visual FoxPro Code

SET LIBRARY TO EDGETSTR
? EDGETSTR("x") && returns the first 16 characters of file "x"

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   WHANDLE wh;
   char FAR *buffer;
   char FAR *pFileName;

   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 = _HandToPtr(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);
   if ((buffer = _Alloca(17)) == 0) {
      _Error(182); // "Insufficient memory"
   }
   _EdGetStr(wh, 0, 15, buffer);
   buffer[16] = '\0';
   _RetChar(buffer);
}

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

See Also

Reference

_EdGetChar( ) API Library Routine
_EdSetPos( ) API Library Routine
_EdGetLinePos( ) API Library Routine

Other Resources

API Library Construction