Use this forum for everything concerning script usage
atagal
Newbie
Posts: 34 Joined: Tue Oct 26, 2010 12:08 am
Post
by atagal » Tue Nov 02, 2010 9:03 pm
Dimitris, how to remove duplicates in delphi?
Code: Select all
lbl := TStringList.Create;
lbl.Duplicates := dupIgnore;
lbl.Sorted := True;
i := 0;
repeat
sqrNum := GetPart (sCat, i, ';');
if (sqrNum <> '') then lbl.Add(trim(sqrNum));
i := i + 1;
until sqrNum = '';
sCat := lbl.CommaText;
lbl.Free;
after many hours i finaly have found some solution but it works with "Sorted=True" only.
on discogs are a lot dublicates labels.
for example:
Cat1, Cat2, Cat3
Label1, Label1, Label2
i wish remove duplicates but not sort it. any hint?
jtclipper
Administrator
Posts: 772 Joined: Tue Aug 10, 2010 12:04 pm
Post
by jtclipper » Wed Nov 03, 2010 8:17 am
From a quick look I think you can use a for loop to iterate through the stringlist, check the value against the entries and add accordingly.
Code: Select all
procedure _add_to_list;
var
j: integer;
begin
if (sqrNum = '') then exit; // get out
for j := 0 to lbl.Count - 1 do begin
if lbl.Strings[ j ] = sqrNum then exit; //get out
end;
lbl.Add( sqrNum );
end;
lbl := TStringList.Create;
i := 0;
repeat
sqrNum := Trim( GetPart(sCat, i, ';') );
_add_to_list;
Inc( i );
until sqrNum = '';
sCat := lbl.CommaText;
lbl.Free;
Dimitris
atagal
Newbie
Posts: 34 Joined: Tue Oct 26, 2010 12:08 am
Post
by atagal » Wed Nov 03, 2010 9:50 am
perfect! thank you!