Janilabo Posted May 22, 2012 Share Posted May 22, 2012 (edited) Returns true if all the values of string array are unique to each other. Example included. TSAAllUnique [scar]function TSAAllUnique(TSA: TStringArray): Boolean; var h, i, i2: Integer; begin h := High(TSA); if (h < 1) then begin Result := (h = 0); Exit; end; for i := 0 to (h - 1) do for i2 := (i + 1) to h do if (i <> i2) then begin Result := (TSA <> TSA[i2]); if not Result then Exit; end; end; var ATSA: T2DStringArray; h, i: Integer; begin ClearDebug; SetLength(ATSA, 9); ATSA[0] := ['Test0', 'Test1', 'Test2', 'Test3']; ATSA[1] := ['Test0', 'Test1', 'Test2', 'Test1']; ATSA[2] := ['Test0', 'Test1', 'Test2', 'Test2']; ATSA[3] := ['Test0', 'Test1', 'Test1', 'Test2']; ATSA[4] := ['Test0', 'Test1', 'Test1', 'Test1']; ATSA[5] := ['Test1', 'Test1', 'Test1', 'Test1']; ATSA[6] := ['Test1', 'Test2', 'Test3', 'Test4']; ATSA[7] := ['Test']; ATSA[8] := []; h := High(ATSA); for i := 0 to h do begin if TSAAllUnique(ATSA) then WriteLn('ATSA[' + IntToSTr(i) + ']: ALL values are unique!') else WriteLn('ATSA[' + IntToStr(i) + ']: ALL values are NOT unique.'); SetLength(ATSA, 0); end; SetLength(ATSA, 0); end.[/scar] Edited May 22, 2012 by Janilabo Quote Link to comment Share on other sites More sharing options...