Identifying the operating system can be performed with Python or Basic language.ComputerName property is solely available for Windows. Basic calls to Python macros help overcome %PRODUCTNAME Basic limitations.
%PRODUCTNAME Basic lacks MacOS X native recognition. Platform identification is possible using %PRODUCTNAME Application Programming Interface (API).Option CompatibleOption ClassModuleOption ExplicitPublic Property Get ComputerName As String If isWindows Then ComputerName = Environ("ComputerName")End Property ' Platform.ComputerNamePublic Property Get DirSeparator As String DirSeparator = GetPathSeparator()End Property ' Platform.DirSeparatorPublic Property Get IsLinux As Boolean isLinux = ( GetGUIType()=4 ) ' Applies to macOS as well End Property ' Platform.isLinuxPublic Property Get IsMacOSX As Boolean isMacOSX = ( OSName="MAC" )End Property ' Platform.isMacOSXPublic Property Get IsWindows As Boolean isWindows = ( GetGUIType()=1 )End Property ' Platform.isWindowsPublic Property Get OSName As String ' Return platform name as "MAC", "UNIX", "WIN" ' Inferred from "Tools.UCB.ShowHelperDialog" function With GlobalScope.Basiclibraries If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") End With Dim keyNode As Object ' com.sun.star.configuration.ConfigurationAccess keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.Common/Help") OSName = keyNode.GetByName("System")End Property ' Platform.OSNamePublic Property Get PathDelimiter As String Select Case OSName Case "MAC", "UNIX" : PathDelimiter = ":" Case "WIN" : PathDelimiter = ";" End SelectEnd Property ' Platform.PathDelimiter
Examples:
With Python>>> from <the_module> import Platform>>> print(Platform().isMacOSX) # object propertyTrue>>> input(Platform().OSName) # object propertyDarwin
From menu.from <the_module> import Platformimport screen_io as uip = Platform()ui.MsgBox(''.join(['isMacOS: ',str(p.isMacOSX)]),0,p.OSName)With %PRODUCTNAME BasicSub Platform_example() Dim p As New Platform ' instance of Platform class MsgBox p.isLinux ' object property Print p.isWindows, p.OSName ' object propertiesEnd Sub ' Platform_example