I have already read that documentation. However, the second and third arguments are always empty after execution of the invoke() method, no matter how I call my python function, and no matter what my python function does.
How does the python function, itself, control what goes into those last two arguments? It seems that those two arguments are totally ignored when the external function is written in python. Is that correct? If not, then what can be done within the python function, itself, to cause values to be placed within those last two arguments?
Does anyone have any sample python code which, when called via invoke(), will actually cause values to be placed within these last two arguments?
Here are three examples which seem to show that python has no way of causing any values to appear in the second and third arguments passed to invoke(). Each of them are invoked via LibreOffice Basic using the code I posted above.
For my first example, assume that my python function is written as follows. When called via the Basic code I listed above, args[0] of the python function will contain the value "a", args[1] will contain "b", and args[2] will contain "c", and the value "foobar: a b c" is returned to the LibreOffice Basic calling program. However, "secondArg" and "thirdArg" always come back empty, with each of their ubound() values set to -1. How should I rewrite my python function to cause values to be placed in "secondArg" and "thirdArg" of my example above?
- Code: Select all Expand viewCollapse view
def pyfunc(*args):
result = 'foobar: ' + ' '.join(args)
return result
Secondly, if I write the python function as follows, a two-element array gets returned to my LibreOffice Basic calling program, but "secondArg" and "thirdArg" still come back empty. The returned two-element array looks like this:
[ 3, "foobar: a b c" ]- Code: Select all Expand viewCollapse view
def pyfunc(*args):
result = 'foobar: ' + ' '.join(args)
return ( len(args), result )
And finally, if I write the function as follows, I get the same results, again with empty "secondArg" and "thirdArg" values coming back after the call.
- Code: Select all Expand viewCollapse view
def pyfunc(a0, a1, a2):
result = 'foobar: ' + str(a0) + ' ' + str(a1) + ' ' + str(a2)
# Python passes arguments by value, so these settings of the three function arguments have
# no effect when the function returns.
a0 = 1000
a1 = ( 1, 2 )
a2 = ( 4000, 5000, 6000, 7000 )
return ( 3, result )
Thank you.