A Quick Rexx Tutorial
This quick tutorial introduces you to Rexx scripting. It assumes that you know how to script or program in at least one other language. Rexx is a platform-independent, standards-based scripting language described in the companion article "Rexx: What You Need to Know."
This article introduces standard, procedural Rexx. For object-oriented Rexx or Java-compatible Rexx programming, visit the Rexx Information web site or see my book Rexx Programmer’s Reference (Wrox, 2005). Rexx is a "power" language, so this tutorial just gets you started. Let’s go.
Rexx Basics
The Rexx language consists of a nucleus of operators (comparison, logical, arithmetic, and string). Rexx features a small instruction set of only a couple dozen instructions, surrounded by a large group of built-in functions. The language is easily extended by using external functions, available in hundreds of free Rexx tools function libraries. Figure 1 shows the basic parts of the Rexx language.
You code external functions in Rexx in the same manner as you do any built-in function (after issuing a statement or two to load the external function library).
Figure 1 The elements of Rexx.
Rexx variables may represent strings—character, bit, or hex. Or they may contain a string that represents a number, as shown in Table 1.
Table 1 Strings that Represent Numbers
Number |
Examples |
Whole or integer |
’3’ or ’+6’ or ’989349829’ |
Decimal or fixed point |
’0.3’ or ’17.3465’ |
Exponential, real, or floating-point |
’1.235E+11’ or ’171.123E+11’ |
Rexx variables are not typed. They contain strings that represent either string or numeric values. If the variable contains a string that can be understood as a number, your script can perform numeric operations with that variable.