ScriptForge.Platform service/text/sbasic/shared/03/sf_platform.xhpPlatform service
ScriptForge.Platform service
The Platform service provides a collection of properties about the current execution environment and context, such as:The hardware platform (architecture, CPU count, machine type, etc)Operating system information (OS type, release, version, etc)The %PRODUCTNAME versionThe current user nameAll properties of the Platform service are read-only.
Service invocation
Before using the Platform service the ScriptForge library needs to be loaded or imported:The examples below in Basic and Python instantiate the Platform service and access the Architecture property.GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")Dim platform As Variantplatform = CreateScriptService("Platform")MsgBox platform.Architecturefrom scriptforge import CreateScriptServicesvc = CreateScriptService("Platform")bas = CreateScriptService("Basic")bas.MsgBox(svc.Architecture)Platform service;ArchitecturePlatform service;ComputerNamePlatform service;CPUCountPlatform service;CurrentUserPlatform service;ExtensionsPlatform service;FontsPlatform service;FormatLocalePlatform service;LocalePlatform service;MachinePlatform service;OfficeLocalePlatform service;OfficeVersionPlatform service;OSNamePlatform service;OSPlatformPlatform service;OSReleasePlatform service;OSVersionPlatform service;PrintersPlatform service;ProcessorPlatform service;PythonVersionPlatform service;SystemLocalePlatform service;UserData
Properties
NameReadonlyTypeDescriptionArchitectureYesStringThe hardware bit architecture. Example: '32bit' or '64bit'ComputerNameYesStringThe computer's network name.CPUCountYesIntegerThe number of central processing units.CurrentUserYesStringThe name of the currently logged user.ExtensionsYesString arrayReturns a zero-based array of strings containing the internal IDs of all installed extensions.FilterNamesYesString arrayReturns a zero-based unsorted array of strings containing the available document import and export filter names.FontsYesString arrayReturns a zero-based array of strings containing the names of all available fonts.FormatLocaleYesStringReturns the locale used for numbers and dates as a string in the format "la-CO" (language-COUNTRY).LocaleYesStringReturns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the SystemLocale property.MachineYesStringThe machine type. Examples are: 'i386' or 'x86_64'.OfficeLocaleYesStringReturns the locale of the user interface as a string in the format "la-CO" (language-COUNTRY).OfficeVersionYesStringThe actual %PRODUCTNAME version expressed as ' %PRODUCTNAME w.x.y.z (The Document Foundation)'.Example: 'LibreOffice 7.4.1.2 (The Document Foundation, Debian and Ubuntu)'OSNameYesStringThe operating system type. Example: 'Darwin, Linux' or 'Windows'.OSPlatformYesStringA single string identifying the underlying platform with as much useful and human-readable information as possible.Example: 'Linux-5.8.0-44-generic-x86_64-with-glibc2.32'OSReleaseYesStringThe operating system's release. Example: '5.8.0-44-generic'OSVersionYesStringThe operating system's build or version.Example: '#50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021'PrintersYesString arrayThe list of available printers as a zero-based array.The default printer is put in the first position of the list (index = 0).ProcessorYesStringThe real processor name. Example: 'amdk6'.This property may return the same value as the Machine property.PythonVersionYesStringReturns the version of the Python interpreter being used as a string in the format "Python major.minor.patchlevel" (ex: "Python 3.9.7").SystemLocaleYesStringReturns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the Locale property.UserDataYesDictionaryReturns a Dictionary instance containing key-value pairs in relation with Tools - Options - User Data dialog.
The following examples in Basic and Python illustrate how to use the Fonts property to write the names of all available fonts to the current Calc sheet starting at cell "A1":Dim oDoc as ObjectDim allFonts as ObjectDim svcPlatform as ObjectSet oDoc = CreateScriptService("Calc")Set svcPlatform = CreateScriptService("Platform")allFonts = svcPlatform.FontsoDoc.setArray("~.A1", allFonts)The example below demonstrates how to create a Calc table with all the values stored in the UserData property, which is a Dictionary service instance:Dim svcPlatform as Object, oUserData as Object, oDoc as ObjectDim arrUserData As Object, currCell As StringSet svcPlatform = CreateScriptService("Platform")oUserData = svcPlatform.UserDataarrUserData = oUserData.ConvertToArray()Set oDoc = CreateScriptService("Calc", ThisComponent)oDoc.SetArray("~.A1", Array(Array("Key", "Value")))oDoc.SetArray("~.A2", arrUserData)The examples above can be written in Python as follows:from scriptforge import CreateScriptServicebas = CreateScriptService("Basic")doc = CreateScriptService("Calc", bas.ThisComponent)svc_platform = CreateScriptService("Platform")all_fonts = svc_platform.Fontsdoc.setArray("~.A1", all_fonts)from scriptforge import CreateScriptServicebas = CreateScriptService("Basic")doc = CreateScriptService("Calc", bas.ThisComponent)svc_platform = CreateScriptService("Platform")user_data = svc_platform.UserDataarr_user_data = [[key, user_data[key]] for key in user_data]doc.SetArray("~.A1", (("Key", "Value"),))doc.SetArray("~.A2", arr_user_data)Platform information with INFO("system") Calc formula