SRL Archive - OSR Help

TPAInATPA help


Haxz

2013-04-03 06:41:48

TPAInATPA(TPA, ATPA, var Index: LongInt);

I know what to place in the TPA and ATPA inside the bracket, but what should I put in "var Index: LongInt"? If someone could, please explain more of this function to me.
Thanks! ;)

Chris

2013-04-03 06:58:39

An integer, after you've called the function, the index in which the TPA is found in the ATPA will be stored in that integer.
So after using the function, ATPA[Index] will be the same as the TPA.

Smidqe

2013-04-03 07:08:29

If the function finds the TPA inside the ATPA then it would result as true. For the "var index : longInt" it would output the index of the ATPA where it found the tpa.

I've got an example for that function:
program new;
var
tpa, tpa2 : TPointArray;
atpa : T2DPointArray;
index : integer;

begin
tpa := [Point(1, 1), Point(2, 2)];
tpa2 := [Point(5, 5), Point(4, 4)]

atpa := [TPointArray([Point(1, 1), Point(2, 2)]), TPointArray([Point(5, 5), Point(4, 4)])];

if tpaInATPA(tpa, atpa, index) then
writeln('index(tpa): ' + toStr(index)); //as the length of atpa is 2 index can be either 0 or 1

if tpaInATPA(tpa2, atpa, index) then
writeln('index(tpa2): ' + toStr(index));

//with the index you can use it to take out specific tpa's from the atpa.
end.

Haxz

2013-04-03 07:23:09

Thanks guys, that cleared up my doubts!