Creates and opens a specified file.

Syntax

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

<oRef>

A reference to a File object.

<filename expC>

The name of the file to create and open. By default, create( ) creates the file in the current directory. To create the file in another directory, specify a full path name for <filename expC>.

<access expC>

The access level of the file to create, 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 and write 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 create( ) to create a file with a name you specify, assign the file the level of access you specify, and open the file. If dBASE Plus can’t create the file (for example, if the file is already open), an exception occurs.

SET SAFETY has no effect on create( ). If <filename expC> already exists, it is overwritten without warning. To see if a file with the same name already exists, use exists( ) before issuing create( ).

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

When you open a file with create( ), the file is empty, so 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.