_EdSetEnv( ) API Library Routine Example
The following example opens for editing a file specified by a parameter. After indenting the first two lines of the file, it uses _EdSetEnv( ) to change the size of a tab stop to 6 characters and then to 9 characters.
SET LIBRARY TO EDSETENV
= EDSETENV("x")
#include <pro_ext.h>
FAR Example(ParamBlk FAR *parm)
{
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))
WHANDLE wh;
EDENV EdEnv;
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);
_EdGetEnv(wh, &EdEnv);
_EdSelect(wh, _EdGetLinePos(wh, 1), _EdGetLinePos(wh, 3));
_EdIndent(wh, 1);
_Execute("WAIT WINDOW 'Press any key\
to change tabs to 6 characters.'");
EdEnv.tabWidth = 6;
_EdSetEnv(wh, &EdEnv);
_Execute("WAIT WINDOW 'Press any key \
to change tabs to 9 characters.'");
EdEnv.tabWidth = 9;
_EdSetEnv(wh, &EdEnv);
}
FoxInfo myFoxInfo[] = {
{"EDSETENV", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};