Sergei,
Oops. OK in this case it could be a problem.
Check out optimaisation in the help.
{$O-} will turn off optimisation.
The help indicates that this can be set with local scope for the
procedure / function. This will prevent optimisation in your method
containing the traversal loop which will then behave the way you expect.
Regards
Andrew Dibley.
> -----Original Message-----
> From: Sergei Stenkov [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 21 March 2001 13:03
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Number of lines in text file
>
>
> Andrew Dibley wrote:
>
> > 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.
>
> It could be when I'd want to test the first element of the
> array to see if
> it's #10,
> since the loop would miss a line if say High(aBuf) = #13
>
> > 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.
>
> Ouch, you're right. Thanks, I should've noticed that myself.
>
> Best regards,
> 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"