obj_set_parent

obj_set_parent sets the parent object.

bool = obj_set_parent(obj, parent)

Return Value

bool is TRUE (1), if the function could set the parent successfully.

Parameters

obj

obj is the object created with obj_create.

parent

parent is an object created with obj_create.

Comment

The 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.

History

Version Description
R2013.2 Only references to objects are copied. See above.
4.1.0 New.

id-1665813