CBL_READ_FILE

Syntax:

call "CBL_READ_FILE" using file-handle
                           file-offset
                           byte-count
                           flags
                           buffer

Parameters:

  Using call prototype (see Key) Picture
file-handle cblt-bytestream-handle pic x(4) comp-5.
file-offset cblt-x8-compx pic x(8) comp-x.
byte-count cblt-x4-compx pic x(4) comp-x.
flags cblt-x1-compx pic x comp-x.
buffer pic x(n). pic x(n).

On Entry:

file-handle
The file handle returned when the file was opened.
file-offset
The offset in the file at which to read. This field is limited to a maximum value of x"00FFFFFFFF" unless bit 4 of the access-mode flag is set when the file is opened using CBL_OPEN_FILE or CBL_CREATE_FILE.
byte-count
The number of bytes to read.
flags
This parameter can take the following values:
0 Standard read
128 Return the current file size in file-offset

On Exit:

file-offset
Contains the current file size on return if flags is set to 128 on entry.
buffer
The buffer into which the bytes are read. It is your responsibility to ensure that the buffer is large enough to hold the number of bytes to be read.

Comments:

The success of the call can be checked by examining RETURN-CODE.

When using this routine to read a file that is contained in a .lbr file, the end-of-file status is not returned. To ensure you only read the file you want, obtain the size of the file first (set flags to 128), and only read up to that size.