Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Returns array of items from TSA by IDs. Ignores invalid ID's.
- [==============================================================================}
- function TSAGet(TSA: TStrArray; IDs: TIntArray): TStrArray;
- var
- i, h, h2, r: Integer;
- begin
- h := High(TSA);
- h2 := High(IDs);
- if ((h2 > -1) and (h > -1)) then
- begin
- SetLength(Result, (h2 + 1));
- for i := 0 to h2 do
- if ((IDs[i] <= h) and (IDs[i] > -1)) then
- begin
- Result[r] := string(TSA[IDs[i]]);
- Inc(r);
- end;
- end;
- SetLength(Result, r);
- end;
- var
- tmp: TStrArray;
- h, i: Integer;
- begin
- ClearDebug;
- tmp := TSAGet(['Test0', 'Test1', 'Test2', 'Test3', 'Test4', 'Test5', 'Test6', 'Test7', 'Test8', 'Test9'], [-1, 1, 2, 3, 4, 999]);
- h := High(tmp);
- for i := 0 to h do
- WriteLn(tmp[i]);
- end.
Advertisement
Add Comment
Please, Sign In to add comment