Writing and running a REXX application
One advantage of the REXX language is its similarity to ordinary English. This similarity makes it easy to read and write a REXX program, as shown in the following examples.
Example of a simple program
To write a line of output, you use the REXX instruction SAY followed by the text you want written.
This program starts with a comment line to identify it as a REXX program. A comment begins with
/*
and ends with */
.
When you run the program, the SAY instruction sends the following output to the terminal device:
Hello world!
Example of a longer program
Even in a longer program, the instructions are similar to ordinary English and are easy to understand. In this example, you call the program ADDTWO, which adds two numbers.
- From a CICS terminal, clear the screen and enter the following
command:
REXX addtwo
- Enter two numbers.
Here is the ADDTWO program. The comment in the program code assumes that the first number entered is 42 and the second number is 21.
When you run the example program, the first PULL instruction assigns the variable
number1 the value
42
. The second PULL instruction assigns the
variable number2 the value 21
. The next line contains an
assignment. The language processor adds the values in number1 and
number2 and assigns the result, 63
, to sum .
Finally, the SAY instruction displays the output line:
The sum of the two numbers is 63.