https://stackoverflow.com/a/8978435/1335492
...shows how to call a python script from LibreOffice BASIC: (How can I call a Python macro in a cell formula in OpenOffice.Org Calc? )
Function invokeScriptFunc(..., args As Array, outIdxs As Array, outArgs As Array)
...
invokeScriptFunc = oScript.invoke(args, outIdxs, outArgs)
end Function
But that doesn't work for me. I get "BASIC runtime error. Argument is not optional" for outArgs. On the other hand, "oScript.invoke(args, Array(), Array())" is not an error.
The example has not been wrong for 10 years, it's unlikely to be wrong today. But I've not got an example of it working with a python script that returns a list: perhaps that is my problem.
The script I am trying to use is:
def MyFunc(a,b):
return [a,b]
I don't get the error when I try
Function invokeScriptFunc(..., args As Array, outIdxs As Array)
...
dim outArgs as array
invokeScriptFunc = oScript.invoke(args, outIdxs, outArgs)
end Function
or
invokeScriptFunc = oScript.invoke(args, outIdxs, array())
but either way, I'm no closer to seeing the return value I want. FWIW, when I "dim outArgs as array", .invoke returns an object with lbound=0 and ubound=-1. outArgs(0) is not valid.
I'm not trying to parse the output: that comes later. I'm just trying to get it to run without error.