No subject


Tue Jun 11 14:29:31 CEST 2019


------
"Blockread" reads count or less *records* from file F. A record is a
block
of bytes with size specified by the Rewrite() or Reset() statement.
[...]

"Reset" opens a file f for reading. [...] If F is an untyped file, the
record size can be specified in the optional parameter L. A default
value of
128 bytes is used. [...]
------

You didn't open the file as "file of char" or "file of byte" but as an
untyped file.... hence the default record size for reading is 128 bytes
and
not as expected one byte. The rtl doesn't adjust the i/o record size for
each operation. It is set at the time you issue the reset() call and
stays
the same while the file is open.

To solve your problem you either have to tell the rtl the default record
size (if you use untyped files) or use a typed file handle (the record
size
is derived from the typed file type information automatically at
runtime)

Changing the declaration of BinaryFile to one of those mentioned should
work
too.

The only thing I wasn't sure about was the default record size which I
correctly remembered to be 128 bytes.

Thomas




More information about the fpc-pascal mailing list