Context English Hausa
basic_2_python.xhp
N0430
help.text
<bookmark_value>Basic;Calling Python</bookmark_value> <bookmark_value>API;SimpleFileAccess</bookmark_value> <bookmark_value>API;PathSettings</bookmark_value> <bookmark_value>API;XScript</bookmark_value>
basic_2_python.xhp
hd_id811571848401485
help.text
<variable id="basic2python"><link href="text/sbasic/guide/basic_2_python.xhp" name="Basic Programming Examples">Calling Python Scripts from Basic</link></variable>
basic_2_python.xhp
N0432
help.text
Calling Python scripts from %PRODUCTNAME Basic macros is possible, and valuable features can be obtained such as:
basic_2_python.xhp
N0433
help.text
<literal>ComputerName</literal> identification or <literal>OSName</literal> detection are possible,
basic_2_python.xhp
N0434
help.text
Basic <literal>FileLen()</literal> function and <link href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1ucb_1_1SimpleFileAccess.html" name="ucb.SimpleFileAccess">com.sun.star.ucb.SimpleFileAccess.</link><literal>getSize()</literal> API function exhibit a 2 Gigabytes file size upper limit that Python helps to overcome,
basic_2_python.xhp
N0435
help.text
<link href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSettings.html" name="util.PathSettings">com.sun.star.util.PathSettings</link> can be normalized,
basic_2_python.xhp
N0436
help.text
and many more.
basic_2_python.xhp
N0437
help.text
A reasonable exposure to %PRODUCTNAME Basic and to <link href="https://api.libreoffice.org/" name="Application Programming Interface">Application Programming Interface (API)</link> features is recommended prior to perform inter-language calls from Basic to Python, to JavaScript or any other script engine.
basic_2_python.xhp
N0438
help.text
Retrieving Python Scripts
basic_2_python.xhp
N0439
help.text
Python scripts can be personal, shared, or embedded in documents. In order to execute them, %PRODUCTNAME Basic needs to be provided with Python script locations. Locating <link href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1script_1_1provider_1_1XScript.html" name="script.provider.XScript">com.sun.star.script.provider.XScript</link> interface compliant UNO objects allows the execution of Python scripts:
basic_2_python.xhp
N0444
help.text
''' Grab Python script object before execution
basic_2_python.xhp
N0445
help.text
' Arguments:
basic_2_python.xhp
N0446
help.text
' macro : as "library/module.py$macro" or "module.py$macro"
basic_2_python.xhp
N0447
help.text
' location: as "document", "share", "user" or ENUM(eration)
basic_2_python.xhp
N0448
help.text
' Result:
basic_2_python.xhp
N0449
help.text
' located com.sun.star.script.provider.XScript UNO service'''
basic_2_python.xhp
N0452
help.text
Dim sp As Object ' com.sun.star.script.provider.XScriptProvider compatible
basic_2_python.xhp
N0463
help.text
Executing Python Scripts
basic_2_python.xhp
N0464
help.text
Syntax
basic_2_python.xhp
N0466
help.text
<literal>opSysName = script.invoke(Array(), in_outs, Array())</literal> ' in_out is an Array