|
|
|
|
|
- Operating mode
- Variable copy rules
Clone (Function) In french: Clone Constructs a copy of a class instance. // There is a traffic light in North Phoenix, at 4725 E. Mayo Blvd. // It is red StopLight is TrafficLight StopLight.Address = "4725 E. Mayo Blvd., Phoenix, AZ" StopLight.Status = DarkRed // Another traffic light must be set at 5599 on the same boulevard // If the object is simply copied... CopyLight is dynamic TrafficLight = StopLight CopyLight.Address = "5599 E. Mayo Blvd., Phoenix, AZ" // The address of StopLight has also changed...! // If the object is cloned... CloneLight is dynamic TrafficLight = Clone(StopLight) // CloneLight contains the same information as StopLight // But if one of it properties is modified, it does not affect the original traffic light // Change the address CloneLight.Address = "5599 E. Mayo Blvd., Phoenix, AZ" // >> StopLight.Address = "4725 E. Mayo Blvd., Phoenix, AZ" CloneLight.Status = DarkRed // >> StopLight.Status = DarkGreen
Syntax
<Result> = Clone(<Source>)
<Result>: Character string Instance of the copied class. <Source>: Character string Instance of the class to be copied. Remarks Operating mode When Clone is used: - a new instance of the same class as the original instance is allocated and the constructor is executed by default (without any parameter or optional parameters).
- a member-by-member copy is performed from the original instance to the new instance.
Remark: The copy takes into account the <Copy> attribute of each member: - <Copy=False> to ignore a member,
- <Copy=Clone> to clone (deep copy).
Variable copy rules | | Type of variables | Effect |
---|
Simple types (integer, real, string, etc.) | The value of the variable is copied. | Arrays | The destination array is a reference to the source array. | Associative arrays | The content of the array is copied. | Queue | The content of the queue is copied. | Stack | The content of the stack is copied. | List | The content of the list is copied. | Object = Dynamic object | The members of the dynamic object are copied to the members of the object. | Object = Object | The members of the source object are copied to the members of the destination object. | Dynamic object = Dynamic object | The destination dynamic object is a reference to the source dynamic object. | Dynamic object = Object | The destination dynamic object is a reference to the source object. | Structure = Dynamic structure | A copy of the structure is performed. Members with the same name are initialized with the existing values. Non-existing members are ignored. | Structure = Structure | A copy of the structure is performed. Members with the same name are initialized with the existing values. Non-existing members are ignored. | Dynamic structure = Dynamic structure | The destination dynamic structure is a reference to the source dynamic structure. | Dynamic structure = Structure | The destination dynamic structure is a reference to the source structure. | Advanced type = Advanced type | The advanced type variable is copied. Properties of the same name are initialized with the existing values. | Advanced type = Dynamic advanced type | The advanced type variable is copied. Properties of the same name are initialized with the existing values. | Dynamic advanced type = Advanced type | The destination dynamic advanced variable is a reference to the source advanced variable. | Dynamic advanced type = Dynamic advanced type | The destination dynamic advanced variable is a reference to the source dynamic advanced variable. |
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|