[fpc-pascal]blockread/write?

Ivan Montes senbei at terra.es
Wed Mar 19 17:12:37 CET 2003


----- Original Message -----
From: "Preben Mikael Bohn" <preben at chin.dk>
> Right now I terminate the program if all data can not be read in one go
and I
> have not have any problems with it. However you are completely right that
I
> should use the returned count, the problem is that I don't know how to
tell
> blockread to start from somewhere within my buffer-array and from the
start.
> Of course I could just copy the buffer-content to another array, but this
> seems awful clumpsy.
>
var  buffer :pByte;

or

type
  tbuffer = array [0..0] of byte;
  pbuffer = ^tbuffer;
var
  buffer :pBuffer;

blockread( f, buffer[ integer index starting at 0 ], desired_bytes_to_read,
actual_bytes_readed );

if you don't want to redefine the type of "buffer" you can type-cast it when
calling blockread
i.e: pByte( buffer ) [ index ]

anyway I don't see what you want to do with that procedure, since you set a
maximum value for the buffer but you don't check if the file is larger than
the buffer. Recursive calls will overwrite the contents of the buffer.

ciao




More information about the fpc-pascal mailing list