SRL Archive - OSR Help

Tagging values onto a TPA


xdarkshadowx

2012-06-04 17:01:26

So I have a TPointArray as the result of a function. but I want to tag an unknown quantity of values onto it, and return them all. so far I have

function CircleCheck(Row,Collumn: Integer): TPointArray;
begin
if (z[row][Collumn].x = HookColor) then
begin
z[row][Collumn].y := 1;
ta[1] := ta[1] + 1;
end
else //useless? meh...
begin
z[row][Collumn].y := 0;
end;
if z[row-1][Collumn-1].x = HookColor then
begin
result := result + z[row-1][Collumn-1]; // part I need help with
end;

end;


I want result to be a list of row/collumn points that came up true. I need help with the syntax of taggin values onto the end of a possibly empty result. please.

result[GetLength(result)].x := Collumn - 1;
result[GetLength(result)].y := Collumn - 1;

would that work? or idk, I don't wanna overwrite any values, and result will be empty at first.

Runaway

2012-06-04 17:08:56

I'm not exactly sure what you're trying to do, but I think AppendTPA() is what you're trying to do. You would be able to replace:


result := result + z[row-1][Collumn-1];

// With:

AppendTPA(result, z[row-1][Collumn-1]);

I'm fairly certain it will increase the TPA length by one and then insert the new value in last, but I always do this to make sure:


lResult := Length(Result);
SetLength(Result, lResult + 1);