Share via


_EdSetEnv( ) API Library Routine

Determines various editor settings.

int _EdSetEnv(WHANDLE wh, *EDENV theEdEnv)
WHANDLE wh;            /* Handle of editing window. */
*EDENV theEdEnv;         /* Editor settings. */

Remarks

For the structure of *EDENV, see _EdGetEnv( ) API Library Routine.

1 is returned if called in a Command or Editor session, otherwise 0 is returned.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

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.

Visual FoxPro Code

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

See Also

_EdGetEnv( ) API Library Routine | _EdLastError( ) API Library Routine | _EdGetEnv( ) API Library Routine | Accessing the Visual FoxPro API