ScriptForge.Basic service/text/sbasic/shared/03/sf_basic.xhpBasic service
ScriptForge.Basic service
The ScriptForge.Basic service proposes a collection of %PRODUCTNAME Basic methods to be executed in a Python context. Basic service methods reproduce the exact syntax and behaviour of Basic builtin functions.
Typical example:svc.MsgBox('This has to be displayed in a message box')ScriptForge.Basic service is limited to Python scripts.
Service invocation
Before using the Basic service, import the CreateScriptService() method from the scriptforge module:from scriptforge import CreateScriptServicesvc = CreateScriptService("Basic")
List of Methods in the Basic Service
ConvertFromUrl
ConvertToUrl
CreateUnoService
DateAdd
DateDiff
DatePart
DateValue
Format
GetDefaultContext
GetGuiType
GetPathSeparator
GetSystemTicks
InputBox
MsgBox
Now
RGB
Xray
interval: A string expression from the following table, specifying the date or time interval.number: A numerical expression specifying how often the interval value will be added when positive or subtracted when negative.date: A given datetime.datetime value, the interval value will be added number times to this date/time value.
interval: A string expression specifying the date interval, as detailed in above DateAdd method.date1, date2: The two datetime.datetime values to be compared.
interval: A string expression specifying the date interval, as detailed in above DateAdd method.date: The date/time from which the result is calculated.firstdayofweek, firstweekofyear: optional parameters that respectively specify the starting day of a week and the starting week of a year, as detailed in above DateDiff method.
Returns the default context of the process service factory, if existent, else returns a null reference.GetDefaultContext is an alternative to the getComponentContext() method available from XSCRIPTCONTEXT global variable or from uno.py module.
svc.GetDefaultContext(): uno
The default component context is used, when instantiating services via XMultiServiceFactory. See the Professional UNO chapter in the Developer's Guide on api.libreoffice.org for more information.
Returns a numerical value that specifies the graphical user interface. This function is only provided for backward compatibility with previous versions.Refer to system() method from platform Python module to identify the operating system.
svc.GetGuiType(): int
n = svc.GetGuiType() GetPathSeparator ---------------------------------------------------------------------- Basic service;GetPathSeparator
GetPathSeparator
Returns the operating system-dependent directory separator used to specify file paths.Use os.pathsep from os Python module to identify the path separator.
Returns the number of system ticks provided by the operating system. You can use this function to optimize certain processes. Use this method to estimate time in milliseconds:
txt = s.InputBox('Please enter a phrase:', "Dear user")s.MsgBox(txt, MB_ICONINFORMATION, "Confirmation of phrase")For in-depth information please refer to Input/Output to Screen with Python on the Wiki. MsgBox -------------------------------------------------------------------------------- Basic service;MsgBox
MsgBox
Displays a dialog box containing a message and returns an optional value. MB_xx constants help specify the dialog type, the number and type of buttons to display, plus the icon type. By adding their respective values they form bit patterns, that define the MsgBox dialog appearance.
svc.Xray(svc.StarDesktop)uno.fileUrlToSystemPath() methoduno.systemPathToFileUrl() methodInput/Output to Screen with Python on the wikiXSCRIPTCONTEXT.getComponentContext() methoduno.getComponentContext() methodplatform.system() methodos.pathsep() method