.. highlightlang:: us .. index:: obj_set_parent .. _obj_set_parent: obj_set_parent ============== .. us.tag obj_set_parent NOTREADYENGLISH obj New410 Changed5502 :ref:`obj_set_parent` sets the parent object. .. function:: bool = obj_set_parent(obj, parent) .. us.return **Return Value** *bool* is TRUE (1), if the function could set the parent successfully. .. us.params **Parameters** .. uparam:: obj *obj* is the object created with :ref:`obj_create`. .. uparam:: parent *parent* is an object created with :ref:`obj_create`. .. us.comment **Comment** The :ref:`obj_set_parent` function copies all key-value pairs from *parent* to *obj* and saves a reference of the parent object. Example:: o = [. a = 1, b = 2 ]; o1 = [. c = 3, d = 4 ]; o1.set_parent(o); *o1* contains the variables a, b, c, d. Instead of ``set_parent`` the following syntax can be used to set the parent object:: o1 = [. __parent__ = o; c = 3, d = 4 ]; If *o* contains pointers to objects, only the pointers will be copied. Before UniPlot R2013.2 a copy of all objects were created. *obj* "inherits" all properties of its *parent*. The child object will also inherit all parent methods. If ``obj.name(1,2)`` is invoked and *obj* does not possess a method ``name``, the parent function will be invoked ``obj.parent.name(1,2)``. If the parent does not possess a function a method ``name`` its parent object is invoked ``obj.parent.parent.name(1,2)`` and so on. .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - R2013.2 - Only references to objects are copied. See above. * - 4.1.0 - New. .. seealso:: :ref:`overview-uniscript-objects`, :ref:`obj_parent`, :ref:`obj_set_methods` :sub:`id-1665813`