FClose()

FCLOSE()

Closes a file opened by  low-level access

Syntax

      FCLOSE( <nHandle> ) --> <lSuccess>

Arguments

<nHandle> DOS file handle

Returns

<lSuccess> Logical TRUE (.T.) or FALSE (.F.)

Description

This function closes an open file with a dos file handle of <nHandle> and writes the associated DOS buffer to the disk. The <nHandle> value is derived from the FCREATE() or FOPEN() function.

Examples

      #include "fileio.ch"
      nHandle := FOpen( "x.txt" )
      ? FSeek( nHandle, 0, FS_END )
      FClose( nHandle )

Compliance

Clipper

Files

Library is rtl

Seealso

FOPEN(), FCREATE(), FREAD(), FWRITE(), FERROR()

C5_FCREATE

 FCREATE()
 Create and/or truncate a binary file to zero-length
------------------------------------------------------------------------------
 Syntax

     FCREATE(<cFile>, [<nAttribute>]) --> nHandle

 Arguments

     <cFile> is the name of the file to create.  If the file already
     exists, its length is truncated to zero without warning.

     <nAttribute> is one of the binary file attributes shown in the table
     below.  If this argument is omitted, the default value is zero.

     Binary File Attributes
     ------------------------------------------------------------------------
     Value   Fileio.ch      Attribute Description
     ------------------------------------------------------------------------
     0       FC_NORMAL      Normal    Create normal read/write file (default)
     1       FC_READONLY    Read-only Create read-only file
     2       FC_HIDDEN      Hidden    Create hidden file
     4       FC_SYSTEM      System    Create system file
     ------------------------------------------------------------------------

 Returns

     FCREATE() returns the DOS file handle number of the new binary file in
     the range of zero to 65,535.   If an error occurs, FCREATE() returns
     -1 and FERROR() is set to indicate an error code.

 Description

     FCREATE() is a low-level file function that either creates a new file or
     opens and truncates an existing file.  If <cFile> does not exist, it is
     created and opened for writing.  If it does exist and can be opened for
     writing, it is truncated to zero-length.  If it cannot be opened for
     writing, FCREATE() returns -1 and FERROR() returns the appropriate error
     value.

     When FCREATE() successfully creates a new file, the file is left open in
     compatibility sharing mode and read/write access mode.  The file
     attribute specified by the <nAttribute> argument is applied to the new
     file when it is closed, allowing writing to a newly created read-only
     file.  For a list of access modes, see FOPEN().

     Since a file handle is required in order to identify an open file to
     other file functions, always assign the return value from FCREATE() to a
     variable for later use.

     Like other file functions, FCREATE() does not use either the DEFAULT or
     PATH settings for its operation.  Instead, it writes to the current DOS
     directory unless a path is explicitly stated.

     Warning!  This function allows low-level access to DOS files and
     devices.  It should be used with extreme care and requires a thorough
     knowledge of the operating system.

 Examples

     .  This example creates a file called Testfile and opens it for
        reading and writing:

        #include "Fileio.ch"

        //
        IF (nHandle := FCREATE("Testfile", FC_NORMAL)) == -1
           ? "File cannot be created:", FERROR()
           BREAK
        ELSE
           FWRITE(nHandle, "Hello there")
           FCLOSE(nHandle)
        ENDIF

 Files   Library is CLIPPER.LIB, header file is Fileio.ch.

See Also: FCLOSE() FERROR() FOPEN()



Clipper and Networking

Clipper and Networking

C5 File Management

C5 File Management Commands and Functions

High Level :

ADIR()* :

Fill a series of arrays with directory information

ADIR( [ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

CLOSE :

Close a specific set of files

CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]

COPY FILE :

Copy a file to a new file

COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>

CURDIR() :

Return the current DOS directory

CURDIR( [ <cDrivespec> ] ) --> cDirectory

DELETE FILE :

Remove a file from disk

DELETE FILE | ERASE <xcFile>

DIR* :

Display a listing of files from a specified path

DIR [ <xcFileSpec> ]

        DIRCHANGE() :

      Change the current DOS directory

       DIRCHANGE(<cDir>) --> nSuccess

DIRECTORY() :

Create an array of directory and file information

DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory

 DIRMAKE()

         Create a directory

        DIRMAKE(<cNewDir>) --> nSuccess

          DIRREMOVE() :

     Remove a directory

       DIRREMOVE(<cDirName>) --> nSuccess

          DISKCHANGE() :

       Change the current DOS disk drive

        DISKCHANGE(<cDrive>) --> lSuccess

          DISKNAME() :

                  Return the current DOS drive

        DISKNAME() --> cDrive

DISKSPACE() :

Return the space available on a specified disk

DISKSPACE( [ <nDrive> ] ) --> nBytes

ERASE :

Remove a file from disk

ERASE | DELETE FILE <xcFile>

FILE() :

Determine if files exist in the default directory or path

FILE( <cFilespec> ) --> lExists

RENAME :

Change the name of a file

RENAME <xcOldFile> TO <xcNewFile>

SET ALTERNATE :

Echo console output to a text file

SET ALTERNATE TO [ <xcFile> [ADDITIVE]]
SET ALTERNATE on | OFF | <xlToggle>

SET DEFAULT :

Set the CA-Clipper default drive and directory

SET DEFAULT TO [ <xcPathspec> ]

SET PATH :

Specify the CA-Clipper search path for opening files

SET PATH TO [ <xcPathspec list> ]

TYPE :

Display the contents of a text file

TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]

Low-level :

FCLOSE() :

Close an open binary file and write DOS buffers to disk

FCLOSE( <nHandle> ) --> lError

FCREATE() :

Create and/or truncate a binary file to zero length

FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle

FERASE() :

Delete a file from disk

FERASE( <cFile> ) --> nSuccess

FERROR() :

Test for errors after a binary file operation

FERROR() --> nErrorCode

FOPEN() :

Open a binary file

FOPEN( <cFile>, [ <nMode> ] ) --> nHandle

FREAD() :

Read characters from a binary file into a buffer variable

FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes

FREADSTR() :

Read characters from a binary file

FREADSTR( <nHandle>, <nBytes> ) --> cString

          FRENAME() :

Change the name of a file

       FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess

FSEEK() :

Set a binary file pointer to a new position

FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition

FWRITE() :

Write to an open binary file

FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] )
    --> nBytesWritten

HEADER() :

Return the current database file header length

HEADER() --> nBytes