Chapter 3. A Quick Tour of Traditional Rexx

Table of Contents
What Is a Rexx Program?
Running a Rexx Program
Elements of Rexx
Writing Your Program
Testing Your Program
Variables, Constants, and Literal Strings
Assignments
Using Functions
Program Control
Subroutines and Procedures

Because this book is for Windows and Unix programmers, it is assumed that you are familiar with at least one other language. This chapter gives an overview of the basic Rexx rules and shows you in which respects Rexx is similar to, or different from, other languages you may already know.

What Is a Rexx Program?

A Rexx program is a text file, typically created using a text editor or a word processor that contains a list of instructions for your computer. Rexx programs are interpreted, which means the program is, like a batch file, processed line by line. Consequently, you do not have to compile and link Rexx programs. To run a Rexx program, all you need is Windows or Unix/Linux, the ooRexx interpreter, and the ASCII text file containing the program.

Rexx is similar to programming languages such as C, Pascal, or Basic. An important difference is that Rexx variables have no data type and are not declared. Instead, Rexx determines from context whether the variable is, for example, a string or a number. Moreover, a variable that was treated as a number in one instruction can be treated as a string in the next. Rexx keeps track of the variables for you. It allocates and deallocates memory as necessary.

Another important difference is that you can execute Windows, Unix/Linux commands and other applications from a Rexx program. This is similar to what you can do with a Windows Batch facility program or a Unix shell script. However, in addition to executing the command, you can also receive a return code from the command and use any displayed output in your Rexx program. For example, the output displayed by a DIR command can be intercepted by a Rexx program and used in subsequent processing.

Rexx can also direct commands to environments other than Windows. Some applications provide an environment to which Rexx can direct subcommands of the application. Or they also provide functions that can be called from a Rexx program. In these situations, Rexx acts as a scripting language for the application.