Janilabo Posted May 22, 2012 Share Posted May 22, 2012 Returns true if all values of string array are the same to each other. Example included. TSAAllSame [scar]function TSAAllSame(TSA: TStringArray): Boolean; var h, i: Integer; begin h := High(TSA); if (h < 1) then begin Result := (h = 0); Exit; end; for i := 1 to h do if (TSA <> TSA[0]) then Exit; Result := True; 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 TSAAllSame(ATSA) then WriteLn('ATSA[' + IntToSTr(i) + ']: ALL values are same!') else WriteLn('ATSA[' + IntToStr(i) + ']: ALL values are NOT same.'); SetLength(ATSA, 0); end; SetLength(ATSA, 0); end.[/scar] Quote Link to comment Share on other sites More sharing options...