PUTENV: Assigning a Value to an Environment Variable

How to:

The PUTENV function assigns a value to an environment variable. The function returns an integer return code whose value is 1 (one) if the assignment is not successful or 0 (zero) if it is successful.

Syntax: How to Assign a Value to an Environment Variable

PUTENV(var_name, var_value)

where:

var_name

Fixed length alphanumeric

Is the name of the environment variable to be set.

var_value

Alphanumeric

Is the value you want to assign to the variable.

Example: Assigning a Value to the UNIX PS1 Variable

The following request assigns the value FOCUS/Shell: to the UNIX PS1 variable.

-SET &P1 = PUTENV('PS1','FOCUS/Shell:');

This causes UNIX to display the following prompt when the user issues the UNIX shell command SH:

FOCUS/Shell:

The following request creates a variable named xxxx and sets it to the value this is a test. It then retrieves the value using GETENV.

-SET &XXXX=PUTENV(xxxx,'this is a test');
-SET &YYYY=GETENV(xxxx);
-TYPE  Return Code: &XXXX,  Variable value: &YYYY

The output is:

Return Code: 0,  Variable value: this is a test