_EdGetPos( ) API Library Routine Example
The following example opens an edit session for a file specified by a parameter. After setting the current insertion point with _EdSetPos( ), a call to _EdGetPos( ) is made to verify that it returns the insertion point offset position. After selecting text with _EdSelect( ), a call to _EdGetPos( ) is made to verify that it returns the anchor point offset position.
SET LIBRARY TO EDGETPOS
= EDGETPOS("x")
#include <pro_ext.h>
void putLong(long n)
{
Value val;
val.ev_type = 'I';
val.ev_long = n;
val.ev_width = 6;
_PutValue(&val);
}
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_READONLY);
_HUnLock(parm->p[0].val.ev_handle);
_EdSetPos(wh, 19);
_PutStr("\n_EdSetPos(wh, 19)");
edpos = _EdGetPos(wh);
_PutStr("\n_EdGetPos(wh) ="); putLong(edpos);
_EdSelect(wh, 5, 12);
_PutStr("\n_EdSelect(wh, 5, 12)");
edpos = _EdGetPos(wh);
_PutStr("\n_EdGetPos(wh) ="); putLong(edpos);
}
FoxInfo myFoxInfo[] = {
{"EDGETPOS", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};