Share via


_EdOpenFile( ) API Library Routine

Opens the specified file in a window, in order to begin an editing session.

WHANDLE _EdOpenFile(TEXT *filename, int mode)
TEXT *filename;            /* File to open. */
int mode;                     /* Mode option. */

Remarks

The following mode options are available: FO_READONLY, FO_WRITEONLY, and FO_READWRITE.

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 an editor session for a file specified by a parameter.

Visual FoxPro Code

SET LIBRARY TO EDOPEN  
= EDOPEN("x")  && opens editor session for file "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);
}

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

See Also

_EdCloseFile( ) API Library Routine | _EdRevert( ) API Library Routine | _EdSave( ) API Library Routine