[fpc-pascal]blockread/write?

Anton Tichawa anton.tichawa at chello.at
Wed Mar 19 22:15:55 CET 2003


On Wednesday 19 March 2003 16:39, you wrote:
>  Anton Tichawa wrote:
> > Well, safety is still important. You should use the returned count in
> > your procedure to be on the safe soide. The end might come sooner than
> > expected.
>
> 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.
>

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:

const MAX_BUFFER_SIZE = 8;

then index runs from 0 up to 7. When you want to access the first array 
entry, you use index 0; when you want to access the nth entry (e. g. n = 4), 
you use index n - 1 (e. g. 4 - 1 = 3).

This direct indexing when writing to or reading from the buffer will save 
resources, such as cpu time, memory, power, ..; and it makes your program 
overall faster. It might increase safety, too, because copying too many times 
by itself might be erroneous due to hardware failures.

Anton Tichawa.

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte 
Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
mobil: +43 664 52 07 907
email: anton.tichawa at chello.at

----------



More information about the fpc-pascal mailing list