I only recently learned about using Low() and High() and it is so much nicer
than 
For I:= 0 to Length(MyArray)-1 Do

That I actually went though all my code replacing the Length() - 1's with
High()

I still end up with a lot of 
SetLength(MyArray,Length(MyArray)+1); 
Every time I want to add one more thing to the array.

Almost all of my  dynamic arrays do this, because I can only add one thing
at a time to the array... and the reason I wanted it to be dynamic in the
first place.  

Is there some nifty way to increase a dynamic array by 1 that is more
elegant?  
Inc(MyArray); would sure be nice

James


>To avoid this kind of error you can use
>
>   for i:= 0 to High(Rails) do
>
>or even
>
>    for i:= Low(Rails) to High(Rails) do

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to