Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

GETENV


Syntax | Return Value | Arguments | Keywords | Examples | See Also | Version History

The GETENV function returns the value of one or more specified environment variables from the environment of the IDL process.

About the Process Environment

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
It is important to realize that environment variables are not an IDL feature; they are part of every process. Although they can serve as a form of global memory, it is best to avoid using them in that way. Instead, IDL heap variables (pointers or object references), IDL system variables, or common blocks should be used in that role. Environment variables should be used for communicating with child processes. One example is setting the value of the SHELL environment variable prior to calling SPAWN to change the shell executed by SPAWN.

Syntax

Result = GETENV( Name [, /ENVIRONMENT] )

Return Value

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.

Arguments

Name

A scalar string or string array variable containing the names of environment variables for which values are desired.

Special Handling of the IDL_TMPDIR Environment Variable

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.

Keywords

ENVIRONMENT

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.

Examples

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') 

See Also

SETENV

Version History

Introduced: Original

ENVIRONMENT keyword modified to work on all platforms: 6.1


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]