Janilabo Posted May 22, 2012 Share Posted May 22, 2012 Breaks TSA to ATSA by values - case-sensitive. Example Included. TSAToATSAByName [scar]function TSAToATSAByName(TSA: TStringArray): T2DStringArray; var i, i2, i3, h, h2, hR, l: Integer; begin h := High(TSA); if (h < 0) then Exit; for i := 0 to h do begin hR := High(Result); for i2 := 0 to hR do begin h2 := High(Result[i2]); for i3 := 0 to h2 do if (TSA = Result[i2][i3]) then Break; if (i3 <= h2) then begin l := Length(Result[i2]); SetLength(Result[i2], (l + 1)); Result[i2][l] := TSA; Break; end; end; if (i2 > hR) then begin SetLength(Result, (hR + 2)); Result[(hR + 1)] := [TSA]; end; end; end; var TSA: TStringArray; ATSA: T2DStringArray; h, h2, i, i2: Integer; begin ClearDebug; TSA := ['Test1', 'Test1', 'Test2', 'Test0', 'Test1', 'Test3', 'Test0', 'Test4', 'Test2', 'Test2', 'Test4', 'Test10', 'Test5', 'Test9', 'Test5', 'Test8', 'Test8', 'Test8', 'Test6', 'Test7', 'Test0', 'Test10', 'Test1', 'Test5', 'Test6', 'Test3', 'Test']; ATSA := TSAToATSAByName(TSA); SetLength(TSA, 0); h := High(ATSA); for i := 0 to h do begin h2 := High(ATSA); for i2 := 0 to h2 do WriteLn('ATSA[' + IntToStr(i) + '][' + IntToStr(i2) + ']: ' + ATSA[i2]); SetLength(ATSA, 0); end; SetLength(ATSA, 0); end.[/scar] Quote Link to comment Share on other sites More sharing options...