Previous:File I/O Directives Main Index Next:The #fclose Directive

#### The #fopen Directive

Users may open a text file using the `#fopen` directive. The syntax is as follows:

FOPEN_DIRECTIVE:

`
  #fopen
` IDENTIFIER "filename" OPEN_TYPE
OPEN_TYPE:
`
  read
` | `write` | `append`

Where IDENTIFIER is an undefined identifier used to reference this file as a file handle, "filename" is any string literal or string expression which specifies the file name. Files opened with the `read` are open for read only. Those opened with `write` create a new file with the specified name and it overwrites any existing file with that name. Those opened with `append` opens a file for writing but appends the text to the end of any existing file.

The file handle identifier created by `#fopen` is always global and remains in effect (and the file remains open) until the scene parsing is complete or until you `#fclose` the file. You may use `#ifdef` FILE_HANDLE_IDENTIFIER to see if a file is open.

Previous:File I/O Directives Main Index Next:The #fclose Directive