[fpc-pascal] Get highest element of a StringList

Jean SUZINEAU jean.suzineau at wanadoo.fr
Mon Sep 12 08:52:35 CEST 2022


As Bart suggested, you can use too the for/in loop:  for s in sl do 
WriteLn( s);

For example:

var
    sl: TStringList;
    s: String;
begin
      sl:= TStringList.Create;
      try
         sl.Add('1');
         sl.Add('2');
         for s in sl do WriteLn( s);
      finally
             FreeAndNil( sl);
             end;
end.

Output:

1
2

This works on arrays and strings too.



More information about the fpc-pascal mailing list