CApphot:Copy
The Copy method duplicates the current CApphot and returns the new object. All properties are copied.
A = CApphot:Copy() |
This method copies an existing CApphot and returns a reference to the new CApphot. You cannot copy a CApphot or any other class object using the trivial statement B = A, as this simply makes the value of B a reference to the object A. In other words, B becomes an alias to A. To get around this, two copy methods are provided by the CApphot class:
1. To create a CApphot that is a copy of the current object, use the Copy method. This creates a new CApphot B before duplicating the values of the current object A. For example,
B = A:Copy() |
-- Object A already exists, B is automatically created. |
2. To create a new CApphot that is a copy of an existing object (including all properties), use the copy constructor, as in
B = CApphot:new(A) |
-- Object A already exists, B is automatically created. |
You can choose the copying syntax that fits best with your script.
The following script fragment copies the members of CApphot A into a new CApphot A2:
|
|
|
-- construct a new CApphot object |
|
-- Set the value of nRadius1 |
|
-- Set the value of nRadius2 |
|
-- Set the value of nRadius3 |
|
-- Measure object at (x,y) in CImage I |
|
-- result: A Mag = 15.256 |
|
-- create a copy of A, including measurements |
|
-- result: B Mag = 15.256 |