Difference between revisions of "CopyTPA"
From SCAR Divi Manual
| Line 18: | Line 18: | ||
TPA := [Point(5, 6), Point(0, 0), Point(1, 1)]; | TPA := [Point(5, 6), Point(0, 0), Point(1, 1)]; | ||
TPA2 := TPA; | TPA2 := TPA; | ||
| − | + | SortTPA(TPA2); | |
WriteLn('TPA passed by reference to TPA2:'); | WriteLn('TPA passed by reference to TPA2:'); | ||
WriteLn('TPA: ' + TPAToStr(TPA)); | WriteLn('TPA: ' + TPAToStr(TPA)); | ||
| Line 25: | Line 25: | ||
TPA := [Point(5, 6), Point(0, 0), Point(1, 1)]; | TPA := [Point(5, 6), Point(0, 0), Point(1, 1)]; | ||
TPA2 := CopyTPA(TPA); | TPA2 := CopyTPA(TPA); | ||
| − | + | SortTPA(TPA2); | |
WriteLn('TPA passed by value to TPA2:'); | WriteLn('TPA passed by value to TPA2:'); | ||
WriteLn('TPA: ' + TPAToStr(TPA)); | WriteLn('TPA: ' + TPAToStr(TPA)); | ||
Latest revision as of 16:55, 12 December 2012
Definition
function CopyTPA(const TPA: TPointArray): TPointArray;
Availability
SCAR Divi 3.28 > Current
Description
Creates a new TPointArray with a copy of every element in the given array TPA. An extended function with additional functionality is available as CopyTPAEx.
Example
var
TPA, TPA2: TPointArray;
begin
TPA := [Point(5, 6), Point(0, 0), Point(1, 1)];
TPA2 := TPA;
SortTPA(TPA2);
WriteLn('TPA passed by reference to TPA2:');
WriteLn('TPA: ' + TPAToStr(TPA));
WriteLn('TPA2: ' + TPAToStr(TPA2));
TPA := [Point(5, 6), Point(0, 0), Point(1, 1)];
TPA2 := CopyTPA(TPA);
SortTPA(TPA2);
WriteLn('TPA passed by value to TPA2:');
WriteLn('TPA: ' + TPAToStr(TPA));
WriteLn('TPA2: ' + TPAToStr(TPA2));
end.Output:
TPA passed by reference to TPA2: TPA: (0,0);(1,1);(5,6) TPA2: (0,0);(1,1);(5,6) TPA passed by value to TPA2: TPA: (5,6);(0,0);(1,1) TPA2: (0,0);(1,1);(5,6)