Product Site

7.4.72.1. Operating System environment variables

To use VALUE to manipulate Windows or Unix-like system environment variables, selector must be ENVIRONMENT. In this case, the variable name need not be a valid Rexx symbol. On Unix-like systems environment variable names are case-sensitive.

VALUE returns the null string for undefined environment variables. You cannot determine whether an environment variable is undefined or has been set to the null string.

Environment variables set by VALUE are not kept after program termination.

Restriction

The values assigned to the variables must not contain any character that is a hexadecimal zero ("00"X). For example:
Call VALUE "MYVAR", "FIRST" || "00"X || "SECOND", "ENVIRONMENT"

sets MYVAR to "FIRST", truncating "00"x and "SECOND".

Here are some more examples:
Example 7.97. Builtin function VALUE
/* Given that an external variable FRED has a value of 4         */
share = "ENVIRONMENT"
say VALUE("fred",7,share)      /* says "4" and assigns           */
                               /* FRED a new value of 7          */

say VALUE("fred", ,share)      /* says "7"                       */

/* Accessing and changing Windows environment entries            */
env = "ENVIRONMENT"
new = "C:\EDIT\DOCS;"
say value("PATH",new,env)   /* says "C:\WINDOWS" (perhaps)       */
                            /* and sets PATH = "C:\EDIT\DOCS;"   */

say value("PATH", ,env)     /* says "C:\EDIT\DOCS;"              */

To delete an environment variable use .nil as the newvalue. To delete the environment variable "MYVAR" specify: value("MYVAR", .NIL, "ENVIRONMENT"). If you specify an empty string as the newvalue like in value("MYVAR", "", "ENVIRONMENT") the value of the external environment variable is set to an empty string which on Windows and Unix-like systems is not the same as deleting the environment variable.

Note

Any changes to Windows or Unix-like system environment variables are not kept after program termination.