FCREATE( ) Function

Example   See Also

Creates and opens a low-level file.

Syntax

FCREATE(cFileName [, nFileAttribute])

Returns

Numeric

Arguments

cFileName

Specifies the name of the file to create. You can include a drive designator and path with the file name. If a drive designator or path isn't included, the file is created in the default directory.

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

nFileAttribute

Specifies the attributes of the file created. The following table lists the file attributes you can specify.

nFileAttribute File attributes
0 (Default) Read-Write
1 Read-Only
2 Hidden
3 Read-Only/Hidden
4 System
5 Read-Only/System
6 System/Hidden
7 Read-Only/Hidden/System

Note that a file created with nFileAttribute other than 0 cannot be written to with FPUTS( ) or FWRITE( ) until the file is closed and opened again.

Use DISPLAY STATUS or LIST STATUS to display or print information about files created and opened with FCREATE( ). DISPLAY STATUS and LIST STATUS give the following information about each file opened or created with a low-level file function:

Remarks

If a file with the name you specify already exists, it is overwritten without warning.

FCREATE( ) assigns a file handle number to the file, which you can use to identify the file in other Visual FoxPro low-level file functions. FCREATE( ) returns the file handle number when a file is created, or returns –1 if the file cannot be created.

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

You cannot open a communication port with FCREATE( ). Use FOPEN( ) to open a communication port.