Invoke(ModuleName: String; FunctionName: String; Params: Array): Variant;
ModuleName. Python module name in the file system or system module name. When a Python module is specified, a file with the *.py extension is used in the file system. Parameter value is case sensitive.
The specified module is searched:
In the Python installation folder next to the python3*.dll file or in the nested Scripts folder.
At the specified path which is set using the PythonPath string parameter in the registry key HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Python. For details see the Connecting External Modules to Foresight Analytics Platform section.
In the folder with installed Foresight Analytics Platform.
In the folder specified using the IPythonUtils.AddFolderToPythonPath method.
FunctionName. Name of executed function. Parameter value is case sensitive.
Params. Array of parameter values sent to function.
The Invoke method executes function in the Python language and returns result of its work.
The ModuleName module is searched for in the current folder, from which the analytics platform has been started. The folders that could be set using the AddFolderToPythonPath method for an object of the PythonUtils class are also taken into account.
If the executed function does not contain input parameters, do not specify Params. Values of parameters in Params can be sent as a separate array or enumerated via a comma. Simple type values, such as, String, Char, Integer, Double, Decimal, Currency, Boolean (types str, int, float, bool in Python), are sent according to Fore syntax without transformations. The Null value corresponds to the None value in the Python language. If a Python function receives an object of any Python class, list, or tuple as an input parameter, create the corresponding object using one of the Fore classes: PythonClassObject, PythonList, PythonTuple.
If the function has parameters with default values, and it is required to send only part of parameters, use named parameters. Named parameters are implemented by the PythonParameter class. Create parameters with required names, set value for them and send them to the Invoke method.
Executing the example requires that the current analytics platform folder contains a Python module named sample.en. The following function is implemented in the module:
def summXY(x, y):
return x + y
Add a link to the Python system assembly.
Sub UserProc;
Var
Result: Variant;
Begin
Result := Python.Invoke("sample", "summXY", 100, 500);
Debug.WriteLine(Result);
End Sub UserProc;
On executing the example a function in the Python language is executed that sums two numbers sent in parameters. The result of function execution is displayed in the development environment console.
See also: