FOPEN()

Open a file.

Syntax

FOPEN( <cFile>, [<nMode>] ) --> nHandle

Arguments

<cFile> Name of file to open.

<nMode> Dos file open mode.

Returns

<nHandle> A file handle.

Description

This function opens a file expressed as <cFile> and returns a file handle to be used with other low-level file functions. The value of <nMode> represents the status of the file to be opened; the default value is 0. The file open modes are as follows:

nModefileio.chMeaning
0FO_READRead only
1FO_WRITEWrite only
2FO_READWRITERead/write
16FO_EXCLUSIVEExclusive read only
32FO_DENYWRITEPrevent others from writing
48FO_DENYREADDeny read only
64FO_DENYNONEShare read only
If there is an error in opening a file, a -1 will be returned by the function. Files handles may be in the range of 0 to 65535. The status of the SET DEFAULT TO and SET PATH TO commands has no effect on this function. Directory names and paths must be specified along with the file that is to be opened.

If an error has occured, see the returns values from FERROR() for possible reasons for the error.
Examples

IF (nH:=FOPEN('X.TXT',66) < 0 ? 'File can't be opened' ENDIF
Status

Ready

Compliance

This function is CA-Clipper compliant

Files

Library is rtl Header is fileio.ch

See Also