[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|             FCREATE             |
+---------------------------------+
FCREATE(<expC>  [, <expN>])

-----------------------------------
Creates and opens file.
Return value - Numeric
-----------------------------------

FCREATE() is a low-level file function that creates a new file <expC>
and opens the file for use.  If a file with the name <expC> already
exists, the file is overwritten.  FCREATE() also assigns the file a
numeric "handle" to identify the file in other FoxPro low-level file
functions.  You may not open communication ports with FCREATE.

When a file is created, FCREATE() returns the file handle number.  If a
file cannot be created for any reason, FCREATE() returns a value of -1.

Files created and opened with FCREATE() can be listed to the screen or a
printer with the DISPLAY STATUS command.  DISPLAY STATUS gives the
following information on low-level files:

        . Drive, directory and file name for each open file

        . File handle number for each file

        . File pointer position in each file

        . Read/write attributes of each file

Clauses
-------

<expC>
        Name of file to be created.  You may include the drive designator, path
and the file name in <expC>.  If a drive designator or path is not
specified, the file is created in the default directory.

<expN>
        DOS attributes to be assigned to file.

<expN>          File Attributes
-----------------------------------

  0                     Read/Write (default)
  1                     Read Only
  2                     Hidden
  3                     Read Only/Hidden
  4                     System
  5                     Read Only/System
  6                     System/Hidden
  7                     Read Only/Hidden/System

+---------------------------------+
|         Program Example         |
+---------------------------------+
IF FILE('errors.txt')              && Does file exist?
        errfile = FOPEN('errors.txt',12) && If so, open read/write
ELSE
        errfile = FCREATE('errors.txt')  && If not create it
ENDIF
IF errfile < 0                     && Check for error opening file
        WAIT 'Cannot open or create output file' WINDOW NOWAIT
ELSE                               && If no error, write to file
        =FWRITE(errfile, 'Error information to be written here')
ENDIF

=FCLOSE(errfile)                   && Close file
MODIFY FILE errors.txt NOWAIT      && Open file in edit window

-----------------------------------

See Also:  CLOSE, FCHSIZE(), FCLOSE(), FCOUNT(), FEOF(), FERROR(),
FFLUSH(), FGETS(), FOPEN(), FPUTS(), FREAD(), FSEEK(), FSIZE(), FWRITE()

-----------------------------------

See Also: CLOSE FCHSIZE() FCLOSE() FCOUNT() FEOF() FERROR()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson