[fpc-pascal]blockread/write?

Preben Mikael Bohn preben at chin.dk
Wed Mar 19 18:29:07 CET 2003


 Anton Tichawa wrote:
> Please post the data declarations (e. g. var Count: Integer; const
> MAX_BUFFER_SIZE = .. etc.). Normally, an index starts from 0 upwards, e. g.
> if you had:

It starts at 1, but that really shouldn't matter that much.

If you really want the other stuff I can give you what I have now, but that is
not really readable :-) :

const
  FILEAR_MAX_BUFFER_SIZE = 500;
...
  if startBufferIndex < realFileSize then
  begin
    {$i-}
    seek(dataFile, startBufferIndex);
    {$i+}
    err := IOResult;
    { xxx error check here deleted }
    count := min(endBufferIndex, realFileSize - 1) - startBufferIndex + 1;

    {$i-}
    blockread(dataFile, fabuffer, count);
    {$i+}
    err := IOResult;
    { xxx error check here deleted }
  end;

As you can see I simply assume that everything is read in to the buffer and I
also know that the remaining file is larger than or equal to the count.

Best regards Preben





More information about the fpc-pascal mailing list