──ADDRESS─────┬────────────────────────────┬──;─── ├─environment─┬────────────┬─┤ │ └─expression─┘ │ └┬───────┬───expression1─────┘ └─VALUE─┘
Address is used to send a single command to a specified environment, code an environment, a literal string, or a single symbol, which is taken to be a constant, followed by an expression. The expression is evaluated, and the resulting command string is routed to environment. After the command is executed, environment is set back to whatever it was before, thus temporarily changing the destination for a single command.
Example:
ADDRESS CMD "DIR C:\STARTUP.CMD" /* OS/2 */
If only environment is specified, a lasting change of destination occurs: all commands that follow (clauses that are neither REXX instructions nor assignment instructions) will be routed to the given command environment, until the next ADDRESS instruction is executed. The previously selected environment is saved.
Example:
Suppose that the environment for a text editor is registered by the name EDIT:
address CMD 'DIR C:\STARTUP.CMD' if rc=0 then 'COPY STARTUP.CMD *.TMP' address EDIT
Subsequent commands are passed to the editor until the next ADDRESS instruction.
Similarly, you can use the VALUE form to make a lasting change to the environment. Here expression1 (which may be just a variable name) is evaluated, and the result forms the name of the environment. The subkeyword VALUE can be omitted as long as expression1 starts with a special character (so that it cannot be mistaken for a symbol or string).
Example:
ADDRESS ('ENVIR'||number)
With no arguments, commands are routed back to the environment that was selected before the previous lasting change of environment was made, and the current environment name is saved. Repeated execution of ADDRESS alone, therefore, switches the command destination between two environments alternately. A null string for the environment name (" ") is the same as the default environment.