Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.3 . Guide To CA-Clipper - <b>fwrite()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 FWRITE()
 Write to an open binary file
------------------------------------------------------------------------------
 Syntax

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

 Arguments

     <nHandle> is the file handle obtained from FOPEN(), FCREATE(), or
     predefined by DOS.

     <cBuffer> is the character string to write to the specified file.

     <nBytes> indicates the number of bytes to write beginning at the
     current file pointer position.  If omitted, the entire content of
     <cBuffer> is written.

 Returns

     FWRITE() returns the number of bytes written as an integer numeric
     value.  If the value returned is equal to <nBytes>, the operation was
     successful.  If the return value is less than <nBytes> or zero, either
     the disk is full or another error has occurred.

 Description

     FWRITE() is a low-level file function that writes data to an open binary
     file from a character string buffer.  You can either write all or a
     portion of the buffer contents.  Writing begins at the current file
     position, and the function returns the actual number of bytes written.

     If FWRITE() results in an error condition, FERROR() can be used to
     determine the specific error.

     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 copies the contents of one file to another:

        #include "Fileio.ch"
        #define F_BLOCK      512
        //
        cBuffer := SPACE(F_BLOCK)
        nInfile := FOPEN("Temp.txt", FO_READ)
        nOutfile := FCREATE("Newfile.txt", FC_NORMAL)
        lDone := .F.
        //
        DO WHILE !lDone
           nBytesRead := FREAD(nInfile, @cBuffer, F_BLOCK)
           IF FWRITE(nOutfile, cBuffer, nBytesRead) < ;
                       nBytesRead
              ? "Write fault: ", FERROR()
              lDone := .T.
           ELSE
              lDone := (nBytesRead == 0)
           ENDIF
        ENDDO
        //
        FCLOSE(nInfile)
        FCLOSE(nOutfile)

 Files   Library is CLIPPER.LIB.


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

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson