Issuing Commands from a program

The following sections explain what a host command environment is, how commands are passed to host command environments, and how to change the host command environment.

What is a Host Command Environment?

An environment for executing commands is called a host command environment. Before a program runs, an active host command environment is defined to handle the commands. . When the language processor encounters a command, it passes the command to the host command environment for processing.

When a REXX program runs on a host system, there is at least one default environment available for executing commands.

The host command environments are as follows:

REXXCICS
This is the default REXX/CICS command environment. All REXX/CICS, SQL, EDIT, RFS, or RLS commands can be issued from this environment. However, CICS commands must be prefixed with CICS, SQL statements with EXECSQL, EDIT commands with EDITSVR, RFS commands with RFS, and RLS commands with RLS.
CICS
This is an optional environment that only issues CICS commands. The first word of the host command string is the command name (for example: SEND, RECEIVE).
EXECSQL
This is an optional environment that issues SQL statements (SELECT) to the CICS/DB2 interface.
EDITSVR
This is an optional environment that creates the edit session.
FLSTSVR
This is an optional environment that executes commands for the File List Utility.
RFS
This is an optional environment that executes commands for the REXX File System.
RLS
This is an optional environment that executes commands for the REXX List System.
Note:
It is recommended that the default environment of REXXCICS be used for all commands (that is, the ADDRESS instruction should not be specified).

How Is a Command Passed to the Host Environment?

The language processor evaluates each expression in a REXX program. This evaluation results in a character string (which may be the null string). The character string is prepared appropriately and submitted to the host command environment. The environment processes the string as a command, and, after processing is complete, returns control to the language processor. If the string is not a valid command for the current host command environment, a failure occurs and the special variable RC contains the return code from the host command environment.

Changing the Host Command Environment

You can change the host command environment either from the default environment (REXXCICS) or from whatever environment was previously established. To change the host command environment, use the ADDRESS instruction followed by the name of an environment.

The ADDRESS instruction has two forms; one affects only a single command, and one affects all commands issued after the instruction.

Determining the Active Host Command Environment

To find out which host command environment is currently active, use the ADDRESS built-in function.

Example
curenv = ADDRESS()

In this example, curenv is set to the active host command environment, for example, REXXCICS.