Condividi tramite


_EdInsert( ) API Library Routine

Inserts the specified number of bytes, starting with the specified TEXT * address, at the insertion point.

void _EdInsert(WHANDLE wh, TEXT *theStr, unsigned long Bytes)
WHANDLE wh;            /* Handle of editing window. */
TEXT *theStr;               /* Address of beginning of insertion
 text. */
unsigned long Bytes;         /* Number of bytes to insert. */

Example

The following example opens an editing session for a file specified by a parameter and inserts the line of text "Hello, world" as the new fourteenth line in the file.

Visual FoxPro Code

SET LIBRARY TO EDINSERT
= EDINSERT("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;

   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);

   _EdSetPos(wh, _EdGetLinePos(wh, 13));
   _EdInsert(wh, "Hello, world\n", _StrLen("Hello, world\n"));
}
FoxInfo myFoxInfo[] = {
   {"EDINSERT", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_EdGetPos( ) API Library Routine | _EdSetPos( ) API Library Routine | Accessing the Visual FoxPro API