Call function
Calls a Lua function with the provided parameters
- Parameters
- Advanced call ?
Function CallFunction(Val Lua, Val FunctionName, Val Parameters = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Lua | - | Arbitrary | ✔ | Lua AddIn or Lua version to run |
| FunctionName | - | String | ✔ | Function name or path in module.func format |
| Parameters | - | Array Of Arbitrary | ✖ | Function parameters |
Returns
Arbitrary - Calling result
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
tip
Any JSON-compatible types and BinaryData are allowed as function parameters
The function must be pre-defined in the context using one of the code execution methods
Caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
Lua = OPI_Lua.CreateVM("Lua54");
OPI_Lua.ExecuteCodeFromString(Lua, "function add(a, b) return a + b end");
Parameters = New Array;
Parameters.Add(1);
Parameters.Add(2);
Result = OPI_Lua.CallFunction(Lua, "add", Parameters);
Result
3