FREAD()
Reads a specified number of bytes from a file.
- Syntax
-
- FREAD( <nHandle>, @<cBuffer>, <nBytes> ) --> nBytes
- Arguments
-
- <nHandle> Dos file handle
- <cBufferVar> 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
cBuffer:=SPACE(500)
IF (nH:=FOPEN('X.TXT))>0
FREAD(Hh,@cBuffer,500)
? cbuffer
ENDIF
FCLOSE(nH)
- Status
- Ready
- Compliance
-
- This function is CA-Clipper compliant, but also extends the possible buffer size to strings greater than 65K (depending on platform).
- Files
-
- Library is rtl
- See Also