set: Set an environment variable

Package: language

Usage

set [varname = valuestring]
reset [varname = valuestring]

Parameters

varname
The environment variable to be defined or set.
valuestring
The new string value of the environment variable.

Description

The CL maintains a list of environment variables, each of which consists of a keyword = value pair. The set and reset operators are used to define new environment variables, or to set new values for old environment variables. The two operators are equivalent with the exception that if the named environment variable is already defined, set will push a new, temporary value for the variable, whereas reset will overwrite the most recent definition of the variable. Environment variables may be examined using the show task or the envget intrinsic function.

A particular use for the environment variables is in the definition of IRAF logical names for directories. If an environment variable is set to a string corresponding to a system-dependent directory name, then the environment variable may then be used within the CL to refer to that directory.

For example,

set     testdir = "/usr/iraf/testdir"           # Unix
set     testdir = "dua2:[iraf.testdir]"         # VMS
task    tst1 = testdir$tst1.cl

New IRAF logicals may be defined in terms or existing IRAF logical names, i.e., logical names are recursively expanded.

set     subdir1 = testdir$subdir1/
task    tst2 = subdir1$tst2.e

If the set command is entered without any arguments the current environment list is printed in the reverse of the order in which the definitions were made. If a variable has been redefined both the final and original definition are shown. The show command can be used to show only the current value.

Examples

1. Define the data directory "dd" on a remote node, and call implot to make plots of an image which resides in the remote directory.

cl> set dd = lyra!/u2/me/data
cl> implot dd$picture

2. Temporarily change the value of the variable printer. The new value is discarded when the bye is entered.

cl> cl
cl> set printer = qms
        ...
cl> bye

See also

show, envget