The feature get returns the value of an environment variable. get is defined in the library class EXECUTION_ENVIRONMENT. So the class APPLICATION inherits from EXECUTION_ENVIRONMENT in order to make get available.

program show_homeimplicitnonecharacter(len=32) :: home_val ! The string value of the variable HOMEinteger::home_len! The actual length of the valueinteger::stat! The status of the value:! 0 = ok! 1 = variable does not exist! -1 = variable is not long enought to hold the resultcall get_environment_variable('HOME', home_val, home_len, stat)if(stat ==0)then write(*,'(a)')'HOME = '//trim(home_val)else write(*,'(a)')'No HOME to go to!'endifendprogram show_home

ANSI MUMPS doesn't allow access to the operating system except possibly through the View command and $View function, both of which are implementation specific. Intersystems' Caché does allow you to create processes with the $ZF function, and if the permissions for the Caché process allow it you can perform operating system commands.

In Caché on OpenVMS in an FILES-11 filesystem ODS-5 mode these could work:

While common environment variables exist as constants within the NSIS script compilation environment (see NSIS documentation), arbitrarily-named environment variables' values may be retrieved using ExpandEnvStrings.

ExpandEnvStrings$0"%PATH%"; Retrieve PATH and place it in builtin register 0.ExpandEnvStrings$1"%USERPROFILE%"; Retrieve the user's profile location and place it in builtin register 1.ExpandEnvStrings$2"%USERNAME%"; Retrieve the user's account name and place it in builtin register 2.

Each REXX interpreter sets its own rules by what identifies the pool in which the environmental variables are named. In addition, each operation system (OS) has their own definition as well. This makes it problematic in the accessing/acquiring of environmental variables. Most programmers know what REXX interpreter they are using, and furthermore, they also know what operating system they are writing the REXX program for, so most programmers hard-wire (explicitly code) the "access-name" of the system environmental variables into the program.

The following will work for

Regina

R4

ROO

for the DOS shell under Microsoft Windows (any version).
(Also successfully tested with Regina under the bash shell in UNIX.)

' ------- Major environment variables -------------------------------------------'DefaultDir$ - The folder path where program files are read/written by default'Platform$ - The operating system on which Run BASIC is being hosted'UserInfo$ - This is information about the user's web browser'UrlKeys$ - Contains informational parameters from the URL submitted when the user connected'UserAddress$ - Contains the IP address of the user'ProjectsRoot$ - The folder path where Run BASIC keeps programming projects'ResourcesRoot$ - The folder path where Run BASIC keeps web-servable files'Err$ - A description of the last runtime error'Err - A numeric code for the last runtime error (errors that have no code use zero)'EventKey$ - The id of the object that generated the last user event'RowIndex - The numeric index of the table or database accessor link that generated the last user event

Seed7 provides the function getenv,
to get the value of an environment variable. Environment variables are highly operating system
dependent. Some variables such as HOME are not always defined and others like PATH use
an operating system dependent format (different delimiters). Seed7 provides the functions
homeDir and getSearchPath
to get the home directory and the search path in an operating system independent manner.

What if some of the variables might not exist? Gather has some discipline for that. The following means that three variables are required (the gather construct fails if they are not found), but shell is optional with a default value of /bin/sh if it is not extracted from the data:

Here, the hash is being used as a function to filter several environment keys to their values via mapcar.

Platform note: On POSIX, environment variables, which are extracted using extern char **environ are assumed to contain UTF-8. On Windows, the GetEnvironmentStringsW function is used to obtain the environment vector as wide character data.

This task was particularly worthwhile because it revealed a discrepancy
in the way 32-bit XPL0 accessed the environment block. A small mod to
Tran's PMODE.ASM DPMI was required to make the 32-bit protected-mode
version work the same as the 16-bit real-mode versions.