[comp.lang.pascal] Saving dynamic structures to d

Kai_Henningsen@ms.maus.de (Kai Henningsen) (04/27/91)

William C. Thompson wct @ po.CWRU.Edu schrieb am 22.04.1991, 06:54

WC>The only drawback at all is that the part where I read from and
WC>write to a file is slow.  I tried BlockWrite and BlockRead,
WC>but those made my files WAY too big.  The file sizes didn't
WC>match the number of bytes I told it to write.  Here is the code
WC>I used ---

The old problem again. For reasons of compatibility with old versions (I assume
that decision broke mor new code than it saved old), an untyped file defaults
to a record length of 128 bytes. Nobody wants that, so open it with reset(f, 1)
or rewrite(f, 1), thus setting the record size to one byte, which is what you
(and everybody else) need. More in the manuals and the online help, I think.

WC>BlockRead(f,p^,size,n)      &     BlockWrite(f,p^,size,n)

WC>Anyone see any problems with this code?  I'm not quite sure what
WC>that 4th parameter is for, either.  I think it's for confirmation
WC>of how got written to disk, but I'm not sure.  There was a buffer

Exactly - when you DON'T specify it, failure to write all you want gives an I/O
error; when you do, it only gives a reduced count in n.

MfG Kai