Application Developer Guide > Developing Portable Applications > Writing System-specific Code
  

Writing System-specific Code
For situations in which system-specific code is necessary, for instance when specifying a filename, PV-WAVE provides two methods for determining which system is running the procedure. The first is the GETPLATFORM standard library routine, and the second is the !VERSION system variable.
The GETPLATFORM routine is the preferred method as it returns a unique, consistent string identifying the current platform. The !VERSION system variable is a structure which contains a mix of hardware and software identifiers that have been added over time as support for new platforms was added and, as such, can be somewhat inconsistent.
The following code segment illustrates the use of GETPLATFORM to allow different commands to be executed for Windows and UNIX:
IF STRMATCH(GETPLATFORM(), 'win') THEN BEGIN
     ; Windows code
ENDIF ELSE BEGIN
     ; UNIX code
ENDELSE
The following table lists the supported PV-WAVE platforms and the string returned by GETPLATFORM for each:
Table D-3: GETPLATFORM string values
Platform
GETPLATFORM returns
32-bit LINUX
'lnx32'
64-bit LINUX
'lnx64'
32-bit Solaris
'sol32'
64-bit Solaris
'sol64'
Mac OS X
'mac64'
32-bit Windows
'win32'
64-bit Windows
'win64'
The !VERSION system variable structure provides three structure elements which may be used to identify the current platform: OS, ARCH, and PLATFORM. The values of !VERSION.OS are listed in the following table:
 
Table D-4: !Version.OS System Variables
Platform
Operating System
!Version.OS
Solaris 32-bit
Solaris
solaris
Solaris 64-bit
Solaris 64
solaris64
Linux 32-bit
Linux
linux
Linux 64-bit
Linux 64
linux64
Mac OS X
Mac OS X
macosx64
32-bit x86 PC
Microsoft Windows
Windows-NT
64-bit x64 PC
Microsoft Windows
Windows-NT

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.