ENVRN

Identify the current operating system and runtime

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
xcall ENVRN(system[, runtime])

Arguments

system

The variable to be loaded with the code of the current operating system: (a or n)

-1 = Other systems

6 = OpenVMS

8 = Unix

25 = Windows Server 2012

27 = Windows Server 2012 R2

28 = Windows 10

29 = Windows Server 2016

31 = Windows UWP

32 = Windows 11

33 = Windows Server 2019

34 = Windows Server 2022

100 = Mono Linux

runtime

(optional) The variable to be loaded with the system code of the current runtime: (or n)

004 = IBM AIX 32-bit

028 = Linux 32-bit

101 = Windows 32-bit (x86)

104 = Windows 64-bit (x64)

200 = OpenVMS Alpha

202 = OpenVMS IA64 / Integrity

304 = IBM AIX 64-bit

428 = Linux 64-bit (x64)

Discussion

The ENVRN subroutine returns decimal codes that identify the operating system and, optionally, the runtime on which the program is running. You can use these values to control program actions that depend on the operating system or runtime.

Tip

When running on Synergy .NET, if you write an agnostic program that is 64 on 64 and 32 on 32, you can use ENVRN to determine the platform. On a 64-bit system, the agnostic program will return 104, while on a 32-bit system, the same program will return 101.

Examples

.define TTCHN           ,1
record
    opsys               ,d2
proc
    open(TTCHN, i, "tt:")
    xcall envrn(opsys)
    display(TTCHN, "This program is running on ")
    case opsys of
      begincase
      6:
        writes(TTCHN, "OpenVMS")
      8:
        writes(TTCHN, "Unix")
      28:
        writes(TTCHN, "Windows 10")
      29:
        writes(TTCHN, "Windows Server 2016")
      endcase
    else 
        writes(TTCHN, "something new")
    stop
end