[fpc-pascal] How to append data to a file of byte?

Bo Berglund bo.berglund at gmail.com
Sun Oct 14 15:40:16 CEST 2018


It seems like I cannot use Append() on a file of byte.
Neither is it allowed to use SeekEOF() on that file type...

I want to log binary data to a logfile and therefore I need to open it
for writing with record size =1 and the file pointer at the eof
location.
But all of the useful functions seem only to work with text files.

What do I use to append binary data to an existing binary file?

This throws an error at SeekEof:

  AssignFile(F, FileName);
  if AppendToFile then
    SeekEof(F)
  else
    Rewrite(F,1);
  BlockWrite(F, Buf[0], Length(Buf));
  CloseFile(F);


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list