To work with the tool in Foresight Analytics Platform 10, use the new interface.
The function wizard for the PythonInvoke function looks as follows:
PythonInvoke(ModuleName, FunctionName, Param,…)
ModuleName. The Python module name in the file system or the system module name. When specifying the Python module in the file system, file with the * .py extension is used.
Search for the specified module:
In the Python installation folder next to the python3*.dll file or in the Scripts subfolder.
At the specified path, which is set with the help of 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 Units to Foresight Analytics Platform section.
In the Foresight Analytics Platform installation folder.
FunctionName. Executed function name.
Param1, Param2, …, ParamN. Parameters sent to function.
NOTE. To define the parameter, specify either the number or the address of the cell where it is located.
It returns function execution result in the Python language.
NOTE. Before using the function, make sure that integration of Foresight Analytics Platform with Python is executed.
The function can contain several parameters. New formulas are added automatically in the formula wizard after the user puts the cursor into the field with parameter. If extra parameters are added, they should be left empty. If the function contains no parameters, leave the Param field empty.
Keep in mind the following when calling a Python function:
The module name and executed function name are case-sensitive. The module name is specified without the .py extension.
The module where function is located must be copied to the Foresight Analytics Platform installation folder or must be imported to the Python library.
Parameters of the function and returned result must have one of the following data types: Null, Boolean, Integer, Double, Decimal (applied only to the result returned by the function), String.
If input and output operations are used in the module, then use the mechanism of critical sections for them.
TIP. For details on writing functions in the Python language and on import of modules into the Python library, see Python documentation.
The table contains examples of formulas using the PythonInvoke function:
Formula | Result | Description |
=PythonInvoke("math", "fabs", 4) | 4 | The module of the 4 number. |
=PythonInvoke("math", "fabs", C3) | 4 | The module of the number from the C3 cell. The C3 cell contains the 4 number. |
=PythonInvoke(C4, "fabs", C3) | 9 | The module of the number from the C3 cell. The C4 cell contains the math text value, while the C3 cell contains -9. |
Parameters used in the formulas:
math. The system module of the Python language containing mathematical functions.
fabs. The Python system function, contained in the math module, that returns the absolute value of a number.
See also: