The GETENV function returns the value of one or more specified environment variables from the environment of the IDL process.
Every process has an environment consisting of environment variables, each of which has an associated string value. Some environment variables always exist, such as PATH, which tells the shell where to look for programs. Others can be added by the user, either interactively via a shell, via a UNIX startup file such as .login, or a via a Windows control panel.
When a process is created, it is given a copy of the environment from its parent process. IDL is no exception to this; when started, it inherits a copy of the environment of its parent process, which may be an interactive shell, the windowing system's desktop environment, or some other process. In turn, any child process created by IDL (such as those from the SPAWN procedure) inherits a copy of IDL's current environment.
| Note |
Result = GETENV( Name [, /ENVIRONMENT] )
Returns the value of the environment variable Name from the environment of the IDL process, or a null string if Name does not exist in the environment. If Name is an array, the result has the same structure, with each element containing the value for the corresponding element of Name.
A scalar string or string array variable containing the names of environment variables for which values are desired.
If you specify 'IDL_TMPDIR' as the value of Name, and an environment variable with that name exists, GETENV returns its defined value as usual. However, if IDL_TMPDIR is not defined, GETENV returns the path of the location where IDL's internals believe temporary files should be written on your system:
Using IDL_TMPDIR in this manner makes it simple for code written in IDL to use the same temporary directory as IDL itself uses, and provides an easy way for the user to override the default.
Set this keyword to return a string array containing all entries in the current process, one variable per entry, in the SETENV format (Variable=Value). If ENVIRONMENT is set, the Name argument should not be supplied.
To print the name of the current UNIX shell, enter the command:
PRINT, 'The current shell is: ', GETENV('SHELL')
To store the path to the directory where IDL believes temporary files should be placed in the variable mytemp, use the following statement:
mytemp = GETENV('IDL_TMPDIR')
Introduced: Original
ENVIRONMENT keyword modified to work on all platforms: 6.1