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


Syntax:     FWRITE(<expN1>, <expC> [,<expN2>])

Purpose:    To write a buffer variable to a specified file.

Arguments:  <expN1> is the file handle obtained previously from
            FOPEN(), FCREATE(), or predefined by DOS.

            <expC> is the character string to write to the specified
            file handle.

            <expN2> indicates the number of bytes to write beginning
            from the current file pointer position.  If omitted, the
            entire contents of the buffer variable are written.

Returns:    A numeric value.

            FWRITE() returns the number of bytes written.  If the value
            returned is equal to <expN2>, the operation was successful.
            If the return value is less than <expN2> or zero, the disk
            is full or an error has occurred.  Check FERROR() for the
            precise DOS error designation.

Library:    EXTEND.LIB

            Warning: These functions allow low level access to DOS
            files and devices.  They should be used with extreme care
            and require a thorough knowledge of the operating system.


----------------------------------- Example --------------------------------

   This example copies the contents of one file to another:

   buffer = SPACE(512)
   infile = FOPEN("Temp.txt")
   outfile = FCREATE("Newfile.txt")
   done = .T.
   *
   DO WHILE .NOT. done
      bytes_read = FREAD(infile, @buffer, 512)
      *
      IF FWRITE(outfile, buffer, bytes_read) < bytes_read
         ? "Write fault: ", FERROR()
         done = .T.
      ELSE
         done = (bytes_read == 0)
      ENDIF
   ENDDO
   *
   FCLOSE(infile)
   FCLOSE(outfile)




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

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