[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|              FREAD              |
+---------------------------------+
FREAD(<expN1>, <expN2>)

-----------------------------------
Returns specified number of bytes from file or communications port.
Return value - Character
-----------------------------------

FREAD begins returning bytes from the current file pointer position and
stops after returning <expN2> bytes or when the end-of-file is
encountered.  In the last case, fewer than <expN2> bytes may be
returned.

<expN1>
        File handle of file or port.

<expN2>
        Number of bytes to be returned.

+---------------------------------+
|         Program Example         |
+---------------------------------+
*** TEST.TXT must exist ***
STORE FOPEN('test.txt') TO file_handle && Open the file

STORE FSEEK(file_handle, 0, 2) TO ifp_size && Move pointer to EOF

STORE FSEEK(file_handle, 0) TO ifp_top && Move pointer to BOF

IF ifp_size <= 0 && Is File empty?
        WAIT WINDOW 'This file is empty!' NOWAIT

ELSE && If not
  l_string = FREAD(file_handle, ifp_size) && Store contents to memory
ENDIF

= FCLOSE(file_handle) && Close the file

-----------------------------------

See Also:  FCHSIZE(), FCLOSE(), FCOUNT(), FCREATE(), FEOF(), FERROR(),
FFLUSH(), FGETS(), FOPEN(), FPUTS(), FSEEK(), FSIZE(), FWRITE()

-----------------------------------

See Also: FCHSIZE() FCLOSE() FCOUNT() FCREATE() FEOF() FERROR()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson