.. could it be that I has never value -1
because S is in the List and you will get for I the position in the List of S.
Delphi-Quellcode:
for S in List do
begin
I := List.IndexOf(S);
while I = -1 do
begin
List.Delete(I);
I := List.IndexOf(S);
end;
end;
edit:
If you want to use TStringList there is an property called
duplicates
This can be set to avoid duplicate entries in the list.
Best regards
Klaus