# 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:

nMode | fileio.ch | Meaning
0 | FO_READ | Read only
1 | FO_WRITE | Write only
2 | FO_READWRITE | Read/write
16 | FO_EXCLUSIVE | Exclusive read only
32 | FO_DENYWRITE | Prevent others from writing
48 | FO_DENYREAD | Deny read only
64 | FO_DENYNONE | Share 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

- FCREATE()
- FERROR()
- FCLOSE()