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.

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

Reply via email to