Janilabo Posted September 3, 2012 Share Posted September 3, 2012 function TSAPick(var TSA: TStrArray; pick_IDs: TIntArray): TStrArray; var h, h2, i, r: Integer; begin TIAUnique(pick_IDs); h := High(pick_IDs); h2 := High(TSA); if ((h2 < 0) or (h < 0)) then Exit; SetLength(Result, (h2 + 1)); for i := 0 to h do if ((pick_IDs[i] <= h2) and (pick_IDs[i] > -1)) then begin Result[r] := TSA[pick_IDs[i]]; Inc(r); end; SetLength(Result, r); if (r <= 0) then Exit; SortTIA(pick_IDs); for i := h downto 0 do if ((pick_IDs[i] <= h2) and (pick_IDs[i] > -1)) then Delete(TSA, pick_IDs[i], 1); end; function TSAToStr(TSA: TStrArray): string; var h, i: Integer; begin h := High(TSA); if (h < 0) then Exit; for i := 0 to (h - 1) do Result := (Result + '''' + TSA[i] + '''' + ','); Result := (Result + '''' + TSA[i] + ''''); end; var TSA: TStrArray; begin ClearDebug; TSA := ['TEST1', 'TEST999', 'TEST2', 'TEST3', 'TEST5252', 'TEST4']; WriteLn('TSA before picking: ' + TSAToStr(TSA)); WriteLn('We picked: ' + TSAToStr(TSAPick(TSA, [1, 4]))); WriteLn('TSA after picking: ' + TSAToStr(TSA)); SetLength(TSA, 0); end. Quote Link to comment Share on other sites More sharing options...