[fpc-pascal] Get highest element of a StringList

Martin Wynne martin at 85a.uk
Sat Sep 10 21:51:24 CEST 2022


On 10/09/2022 17:01, James Richters via fpc-pascal wrote:

> For Loop := 0 to MyStringList.Count-1 do
> 
> It would be nice to not have the -1

I don't understand what is wrong with Count-1, but you can get the 
highest index like this if you wish:

high_index:=Length(Trim(MyStringList.Text))-Length(StringReplace(Trim(MyStringList.Text),#13,'',[rfReplaceAll]));

Martin.


More information about the fpc-pascal mailing list