FRead()

FREAD()

Reads bytes from a file opened by low-level access

Syntax

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

Arguments

<nHandle> Dos file handle

<cBuffer> Character expression passed by reference.

<nBytes> Number of bytes to read.

Returns

<nBytes> the number of bytes successfully read from the file. <nHandle>

Description

This function reads the characters from a file whose file handle is <nHandle> into a character memory variable expressed as <cBuffer>. The function returns the number of bytes successfully read into <cBuffer>.

The value of <nHandle> is obtained from either a call to the FOPEN() or the FCREATE() function.

The <cBuffer> expression is passed by reference and must be defined before this function is called. It also must be at least the same length as <nBytes>.

<nBytes> is the number of bytes to read, starting at the current file pointer position. If this function is successful in reading the characters from the file, the length of <cBuffer> or the number of bytes specified in <nBytes> will be the value returned. The current file pointer advances the number of bytes read with each successive read. The return value is the number of bytes successfully read from the file. If a 0 is returned, or if the number of bytes read matches neither the length of <cBuffer> nor the specified value in <nBytes> an end-of-file condition has been reached.

Examples

      #include "fileio.ch"
      cBuffer := Space( 500 )
      IF ( nH := FOpen( "x.txt" ) ) == F_ERROR
         FRead( nH, @cBuffer, 500 )
         ? cbuffer
      ENDIF
      FClose( nH )

Compliance

Clipper

Platforms

All (64K)

Files

Library is rtl

Seealso

BIN2I(), BIN2L(), BIN2W(), FERROR(), FWRITE()

3 responses to “FRead()

  1. Pingback: Harbour All Functions – F | Viva Clipper !

  2. Pingback: Harbour Files and Folders Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.