Commands

From a Rexx program you can pass commands to Windows, OS/2 and Unix/Linux shells or to applications designed to work with Rexx. When used to run operating system commands, Rexx becomes a powerful substitute for the Windows Batch Facility or Unix shell scripts. You can use variables, control structures, mathematics, and parsing, and the full object oriented features of Rexx.

Applications that are designed to work with Rexx are often referred to as scriptable applications. To work with Rexx, a scriptable application registers a command environment with Rexx. An environment serves as a kind of workspace shared between Rexx and the application that accepts application commands issued from your Rexx programs.

For example, many editors provide a command prompt or dialog box from which you can issue commands to set margins or add lines. If the editor is scriptable from Rexx, you can issue the same editor commands from a Rexx program. These Rexx programs are referred to as macros.

When an application runs a Rexx macro, Rexx directs commands to the application's environment. The application processes the command, and returns a status indicator as a return code.

The Rexx ADDRESS instruction allows you select which named command environment commands get directed to. There is always at least one active command environment, and all Rexx programs start with a default environment selected. For programs launched from a command shell, an operating-system-specific command handler is the normal default. Applications (such as an editor) can choose whether or not to make their own command environment the default.