# OPEN()

Syntax:

Then: aa = OPEN(filename,mode)

"filename" is the name of the file to be opened.
"mode" is the access mode to use (see below).
"aa" is the file handle.

Parameters

mode r - read access
w - write access
c - create if doesn't exist
0 - truncate if already exists
b - binary mode
t - text mode

Version Ref: 4.5 (not included in filePro Lite)

In Version 5.7.04, and new flag A was added.

Anything written to the file will be appended to the end of the file.

Description:

This function returns a file handle to access the opened file through the other file I/O functions.

If the file cannot be opened, a negative number is returned. This number is the negative of the system error number.

Note: The file handle returned is analogous to the file handles used internally by the operating system, but the numbers are not necessarily the same. Mode flags can be combined. For example, rwb means read and write access, in binary mode. If neither "r" or "w" is supplied, read-only is used.

Binary/text mode does not affect Unix systems, as Unix makes no distinction. Under MS-DOS, you must make sure to specify binary/text mode as appropriate. If neither is specified, binary mode is used. Note that for portability purposes, you should specify text mode under Unix if appropriate.

Examples:

Then: mo = "/tmp/" { @id { @rn
Then: tf = open(mo,"rwc0")

Set a filename based on the user id and record number being updated. Open this file for reading and writing. Create the file if it doesn't exist, and truncate it, if does. This file can now be used by referring to it as "tf" with most of the other file I/O functions.