Implementing Dynamic Functions Using Scripts
You can provide a script implementation of your dynamic methods by using the API of the dynamic model interpreter or by loading a script file to a dynamic server. As member functions are not supported “as is” by Script the name of the Script function must be built both from the class name and the method name, as follows:
<class_name>_<method_name>(obj)
where the value passed to the first argument of the function will be the class instance on which the method is called.
The syntax for declaring a dynamic method using Script is shown in the following example.
Example
Let us assume you have defined a dynamic class Network; do the following to implement the dynamic method display(string title):
function Network_display(obj, title) {
....
}
The first argument, obj, is the instance of your dynamic class Network on which the method is called. You can also invoke this method using the member function callFunction from your C++ code or using an execCallback from a component.
Script Implementation and Static Classes
It is possible to declare a dynamic function with a static class ( inheriting from IlsDynObject) and to provide a script implementation for this function. To do so, use the function DeclScriptFun. Note that this declaration should be performed before Script proxies are built, that is before any script file is loaded. This method should be passed an Script implementation in a script file using the standard notation (className_funcName).