FOPEN( ) Function

Example   See Also

Opens a file for use with low-level file functions.

Syntax

FOPEN(cFileName [, nAttribute])

Returns

Numeric

Arguments

cFileName

Specifies the name of the file to open. cFileName can include a path to open files in directories, folders, drives, or volumes not in the current Microsoft Visual FoxPro search path. If a path isn't included, Visual FoxPro searches for the file in the following locations:

nAttribute

Specifies read-write privileges or a buffering scheme for the file you open. The following table lists each number you can include in nAttribute, and the read-write file privileges and buffering scheme it establishes.

nAttribute Read-Write privileges Buffered/unbuffered
0 (Default) Read Only Buffered
1 Write-Only Buffered
2 Read and Write Buffered
10 Read-Only Unbuffered
11 Write-Only Unbuffered
12 Read and Write Unbuffered

If nAttribute isn't included, or if nAttribute evaluates to 0, the file is opened as read-only and is buffered.

Note   Visual FoxPro will not recognize a path name properly if a disk or directory name contains an exclamation point (!).

Remarks

If FOPEN( ) successfully opens the file, the file handle number of the file is returned. FOPEN( ) returns –1 if the file cannot be opened.

Tip   Assign the file handle number to a memory variable so you can access the file by the memory variable in other low-level file functions.

The following information about files opened with FOPEN( ) can be displayed or sent to a printer with DISPLAY STATUS or LIST STATUS.