AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones varias de WINDEV
  • Operating mode
  • Variable copy rules
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Clone (Function)
In french: Clone
Constructs a copy of a class instance.
Example
// 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 variablesEffect
Simple types (integer, real, string, etc.)The value of the variable is copied.
ArraysThe destination array is a reference to the source array.
Associative arraysThe content of the array is copied.
QueueThe content of the queue is copied.
StackThe content of the stack is copied.
ListThe content of the list is copied.
Object = Dynamic objectThe members of the dynamic object are copied to the members of the object.
Object = ObjectThe members of the source object are copied to the members of the destination object.
Dynamic object = Dynamic objectThe destination dynamic object is a reference to the source dynamic object.
Dynamic object = ObjectThe destination dynamic object is a reference to the source object.
Structure = Dynamic structureA copy of the structure is performed. Members with the same name are initialized with the existing values. Non-existing members are ignored.
Structure = StructureA 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 structureThe destination dynamic structure is a reference to the source dynamic structure.
Dynamic structure = StructureThe destination dynamic structure is a reference to the source structure.
Advanced type = Advanced typeThe advanced type variable is copied. Properties of the same name are initialized with the existing values.
Advanced type = Dynamic advanced typeThe advanced type variable is copied. Properties of the same name are initialized with the existing values.
Dynamic advanced type = Advanced typeThe destination dynamic advanced variable is a reference to the source advanced variable.
Dynamic advanced type = Dynamic advanced typeThe destination dynamic advanced variable is a reference to the source dynamic advanced variable.
For more details, see Copying and cloning.
Component: wd290vm.dll
Versión mínima requerida
  • Versión 25
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 26/05/2022

Señalar un error o enviar una sugerencia | Ayuda local