Janilabo Posted May 22, 2012 Share Posted May 22, 2012 Removes duplicates from array of string. Example included. TSAUnique [scar]procedure TSAUnique(var TSA: TStringArray); var h, h2, i, i2, i3, d: Integer; begin h := High(TSA); if h < 1 then Exit; for i := (h - d) downto 1 do for i2 := (i - 1) downto 0 do if TSA = TSA[i2] then begin h2 := High(TSA); for i3 := i to (h2 - 1) do TSA[i3] := TSA[(i3 + 1)]; SetLength(TSA, h2); Inc(d); Break; end; end; var h, i: Integer; TSA: TStringArray; str: string; begin ClearDebug; TSA := ['Test0', 'Test1', 'Test1', 'Test2', 'Test0', 'Test3', 'Test3', 'Test2', 'Test4']; TSAUnique(TSA); h := High(TSA); for i := 0 to h do if (i < h) then str := (str + TSA + ', ') else str := (str + TSA); WriteLn(str); str := ''; SetLength(TSA, 0); end.[/scar] Quote Link to comment Share on other sites More sharing options...