Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The "real" answer is the answer posted by Doug above. The purpose of this response is to show rudimentary code that functions based on the advice provided by Doug. While the code below works, modifications to the basic code structure have tended to fail. As the rudimentary minimally altered code works, these shortcomings can eventually be overcome through further research and trial and error. For now, this is usable code for conducting further experimentation.

Uno Basic function below:

Function dblTestPython(dblValue) As Double
        On Error Goto HandleError1001 
        dim a(0), b(0), c(0) as variant 
        a(0)= Forms("MainForm").Controls("Field1").value
        scpr = ThisComponent.getScriptProvider
        scmod = scpr.getScript("vnd.sun.star.script:call_me.py$call_me?language=Python&location=user")
        returnFromPython = scmod.invoke(a,b,c)
        print returnFromPython      
        Exit Function
    HandleError1001:
        resume next
End Function

Python script invoked by the Basic function above:

import os
def call_me(a):
    z = a * 5 
    return z

The "real" answer is the answer posted by Doug above. The purpose of this response is to show rudimentary code that functions based on the advice provided by Doug. While the code below works, modifications to the basic code structure have tended to fail. As the rudimentary minimally altered code works, these shortcomings can eventually be overcome through further research and trial and error. For now, this is usable code for conducting further experimentation.

Uno Basic function below:

Function dblTestPython(dblValue) As Double
        On Error Goto HandleError1001 
        dim a(0), b(0), c(0) as variant 
        a(0)= Forms("MainForm").Controls("Field1").value
        scpr = ThisComponent.getScriptProvider
        scmod = scpr.getScript("vnd.sun.star.script:call_me.py$call_me?language=Python&location=user")
        returnFromPython = scmod.invoke(a,b,c)
        print returnFromPython      
        Exit Function
    HandleError1001:
        resume next
End Function

Python script invoked by the Basic function above:

import os
def call_me(a):
    z = a int(a) * 5 
    return z