Sergei,
What you are seeing is the result of compiler optimisation.
At ASM level a decrement loop is more efficient (1 less subtraction)
and the Delphi optimiser will do this for you if it can. So no problem.
By the way, your test of
if (aBuf[i] = #13) and (aBuf[i+1] = #10) then begin
will cause a read beyond the buffer contents on the last loop iteration.
Regards
Andrew Dibley
> -----Original Message-----
> From: Sergei Stenkov [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 21 March 2001 12:10
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Number of lines in text file
>
>
> Hello,
>
> Just curious what's going on here.
> In debug mode can see i = Length(aBuf) when it first steps
> into the loop
> And it goes from Length down to 0 instead of 0 to Length
>
> repeat
> BlockRead(F2, aBuf, SizeOf(aBuf), iNumRead);
> for i := 0 to Length(aBuf) - 1 do begin
> if (aBuf[i] = #13) and (aBuf[i+1] = #10) then begin
> Inc(iRows);
> end;
> end;
>
> for i := 0 to Length(aBuf) - 1 do begin
> aBuf[i] := #0;
> end;
> until iNumRead = 0;
>
> Tried using Low and High instead of Length - same thing.
>
> Why ?
>
> Does it have anything to do with aBuf being a static array
> declared as:
>
> aBuf: array[1..65536] of Char;
>
> Thank you,
> Sergei
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"