Opens a specified file.

Syntax

<oRef>.open(<filename expC>[, <access expC>])

<oRef>

A reference to a File object.

<filename expC>

The name of the file to open. Wildcard characters are not allowed; you must specify the actual file name.

If you specify a file without including its path, dBASE Plus looks for the file in the current directory, then in the search path(s) you specified with SET PATH, if any. If you specify a file without including its extension, dBASE Plus assumes no extension. If the named file cannot be found, an exception occurs.

<access expC>

The access level of the file being opened, as shown in the following table. The access level string is not case-sensitive, and the characters in the string may be in any order. If omitted, the default is read-only text file. Append is a more restrictive version of write; the data is always added to the end of the file

<access expC>

Access level

"R"

Read-only text file 

"W"

Write-only text file 

"A"

Append-only text file 

"RW"

Read and write text file 

"RA"

Read and append text file 

"RB"

Read-only binary file 

"WB"

Write-only binary file 

"AB"

Append-only binary file 

"RWB"

Read and write binary file 

"RAB"

Read and append binary file 

Property of

File

Description

Use open( ) to open a file with a name you specify and assign the file the level of access you specify. If dBASE Plus can’t open the file (for example, if the file is already open), an exception occurs.

The open( ) method can also be used to access StdIn and StdOut, enabling direct communication with a web server. To do this, set the parameter <filename expC> to "StdIn" to receive data, or "StdOut" to transmit.

To open StdIn use:  To open StdOut use:

fIn = new File( )     fOut = new File( )

fIn.open( "StdIn", "RA")  fOut.open( "StdOut", "RA")

To use other File methods, such as read( ) and write( ), first open a file with open( ) or create( ).

If you open the file with append-only or read and append access, the file pointer is positioned at the end-of-file, after the last character. For other access levels, the file pointer is positioned at the first character in the file. Use seek( ) to position the file pointer before reading from or writing to a file.