Identifying the operating system can be performed with Python or Basic language.%PRODUCTNAME Basic lacks Mac OS X native recognition while ComputerName property is solely available for Windows. Basic calls to Python macros help overcome such limitations.
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 Mac OS X as well End Property ' Platform.isLinuxPublic Property Get IsWindows As Boolean isWindows = ( GetGUIType()=1 )End Property ' Platform.isWindowsPublic Property Get OSName As String Select Case GetGUIType() Case 1 : OSName = "Windows" Case 4 : OSName = "Linux" End SelectEnd Property ' Platform.OSNamePublic Property Get PathDelimiter As String Select Case OSName Case "Linux" : PathDelimiter = ":" Case "Windows" : 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