obj_set_methods¶
obj_set_methods sets the methods (member functions) for the given object.
-
bool = obj_set_methods(obj, m)
Return Value
bool is TRUE (1) if the function was successful or FALSE (0) if an error occurred.
Parameters
-
obj
obj is the object created with obj_create.
-
m
m is an object created with obj_create which contains the names of the methods (see Comment).
Comment
Note
You should not invoke this function directly. Call 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:
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;
}
id-1457530