Code: Select all
REM ***** BASIC *****
function Main()as string
' Get the BASIC code
if BasicLibraries.getByName("Standard").hasByName("Module1") then
Main = BasicLibraries.getByName("Standard").getByName("Module1")
end if
end function
sub message_button(button)
doc = ThisComponent
doc.getText().setString("Hello World! ~ Using BASIC" + _
chr(13) + chr(13) + Main())
end sub
sub clear_button(button)
doc = ThisComponent
doc.getText().setString("")
end sub
For example, in the following code, how would the Main() function be written to retrieve the python script...
Code: Select all
# coding: utf-8
from __future__ import unicode_literals
import uno
import sys
def Main():
"""Get the Python code """
# ...huh? how to do this?
s = "The Python script should be returned here... \n\n"
s += "FYI: Execute action for Message and Clear push buttons: \n"
s += "Module.py$message_button (document, Python) \n"
s += "Module.py$clear_button (document, Python) \n"
return s
def message_button(button):
doc = XSCRIPTCONTEXT.getDocument()
doc.getText().setString("Hello World! ~ Using Python: " + sys.version.split(" ")[0] +
"\n\n" + Main())
def clear_button(button):
doc = XSCRIPTCONTEXT.getDocument()
doc.getText().setString("")
g_exportedScripts = message_button, clear_button,
Thanks, Ian.