Creates and opens a low-level file.
FCREATE(cFileName [, nFileAttribute])
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 does not recognize a path name properly if a disk or directory name contains an exclamation point (!).
Specifies the attributes of the file created. The following table lists the file attributes you can specify.
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:
nFileAttribute File attributes
The drive, directory, and file name
The file handle number
The file pointer position
The read/write attributes
- The drive, directory, and file name
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.
|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.
IF FILE('errors.txt') && Does file exist? gnErrFile = FOPEN('errors.txt',12) && If so, open read/write ELSE gnErrFile = FCREATE('errors.txt') && If not create it ENDIF IF gnErrFile < 0 && Check for error opening file WAIT 'Cannot open or create output file' WINDOW NOWAIT ELSE && If no error, write to file =FWRITE(gnErrFile , 'Error information to be written here') ENDIF =FCLOSE(gnErrFile ) && Close file IF gnErrFile > 0 MODIFY FILE errors.txt NOWAIT && Open file in edit window ENDIF