.. highlightlang:: us .. index:: obj_set_methods .. _obj_set_methods: obj_set_methods =============== .. us.tag obj_set_methods ENGLISH New410 obj :ref:`obj_set_methods` sets the methods (member functions) for the given object. .. function:: bool = obj_set_methods(obj, m) .. us.return **Return Value** *bool* is TRUE (1) if the function was successful or FALSE (0) if an error occurred. .. us.params **Parameters** .. uparam:: obj *obj* is the object created with :ref:`obj_create`. .. uparam:: m *m* is an object created with :ref:`obj_create` which contains the names of the methods (see Comment). .. us.comment **Comment** .. note:: You should not invoke this function directly. Call :ref:`set_method_table` instead. To add a new function (member function or method) to an object a new object must be created that contains the pair "method name" and the UniScript "function name". Example: .. code-block:: us :emphasize-lines: 2,3 obj = obj_create() m = obj_create(); m.test = "my_test"; obj.set_methods(m); When the method ``test`` is invoked:: obj.test(1,2,3) the UniScript interpreter will call the function "my_test". The first parameter is the object *obj*. Here is the UniScript function "my_test":: def my_test(ob, a, b, c) { // do something with ob, a, b, c return 123; } .. seealso:: :ref:`overview-uniscript-objects`, :ref:`obj_methods`, :ref:`obj_set_parent`, :ref:`obj_parent` :sub:`id-1457530`