Skip to main content

Call function

Calls a Lua function with the provided parameters

Function CallFunction(Val Lua, Val FunctionName, Val Parameters = Undefined) Export

ParameterCLI optionTypeRequiredDescription
Lua-ArbitraryLua AddIn or Lua version to run
FunctionName-StringFunction name or path in module.func format
Parameters-Array Of ArbitraryFunction parameters
Returns

Arbitrary - Calling result

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