Reading a File in Sequential Order [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
Reading a File in Sequential Order
SPL uses the FREAD intrinsic to read all or part of a record in a
sequential file with fixed- or variable-length records. A logical record
pointer points to the next record to be read. When any part of a record
is read, the pointer advances to the next record.
HP C/XL has several ways to read records. The fgets function is probably
the closest to the SPL action: a requested number of bytes or all the
characters up to the end of the record are read into a buffer. If the
end of record was reached, HP C/XL marks it by appending a '\n'
(linefeed) character to the record data in the buffer. In any case, HP
C/XL appends a '\0' (NUL) character to mark the end of the data in the
buffer.
Alternatively, the HP C/XL fread function can be used to read
fixed-length binary data into a structure, such as an array or struct.
Since fread does not recognize file record boundaries, you need to be
sure the sizes you supply add up correctly.
The conventional means of performing I/O in HP C/XL is to view data files
as a "stream" of text (ASCII characters) in variable-length records.
The functions contained in the HP C/XL library provide a rich set of
formatted I/O operations, greatly simplifying the multiple steps which
are necessary in SPL. Consideration of fixed-length record operations is
required only to read files created in this manner by other programs, or
to create files for programs that expect to read fixed-length records.
MPE/iX 5.0 Documentation