Janilabo

Janilabo | TSARemove() [SCAR Divi]

Apr 27th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.81 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Removes items from TSA with index positions (x). DYNAMIC deletion.                  
  3. [==============================================================================}
  4. procedure TSARemove(var TSA: TStrArray; x: TIntArray);
  5. var
  6.   i, h, h2: Integer;
  7. begin
  8.   h := High(TSA);
  9.   h2 := High(x);
  10.   if ((h > -1) and (h2 > -1)) then
  11.     for i := 0 to h2 do
  12.       if ((x[i] <= h) and (x[i] > -1)) then
  13.       begin
  14.         Delete(TSA, x[i], 1);
  15.         Dec(h);
  16.       end;
  17. end;
  18.  
  19. var
  20.   tmp: TStrArray;
  21.   h, i: Integer;
  22.  
  23. begin
  24.   ClearDebug;
  25.   tmp := ['TEST1', 'Test1', 'Test2', 'TEST2', 'TEST3', 'Test3', 'TEST4', 'Test4'];
  26.   TSARemove(tmp, [6, 4, 3, 0]);
  27.   h := High(tmp);
  28.   for i := 0 to h do
  29.     WriteLn(tmp[i]);
  30. end.
Advertisement
Add Comment
Please, Sign In to add comment