The REstructured eXtended eXecutor language is an integral part of the OS/2 operating system.
REXX is:
REXX programs must begin with a comment.
The REXX source code is simple ASCII text prepared with a text editor
Included with OS/2 are the E.EXE and EPM.EXE editors.
REXX programs must use the file extension CMD.
There are three methods of running your program:
We will not cover them here but OS/2 REXX supports debugging options. Look-up TRACE and the REXX environment variable RXTRACE. Note that PMREXX supports TRACE.
/* This is a comment */
"Word" 'Multi word phrase' "Joe's Bar" 'Isn''t this strange?'
HERE:
45 -10.1 5.0E-1
SAY 'Simon says: "Type this"'
Variable names use the symbols:
a-z, A-Z, 0-9, !, ?, _
Variable names cannot begin with a number.
| A | a |
| A_B | ?why |
| ALPHA | OK? |
| ALPHA2 | free.1a |
| alpha | free.1 |
| Alpha | multi_segment_ed |
| aLPha |
Note that REXX is not case sensitive, all of the "ALPHA" forms are the same variable.
Complex Variables
Names.I Names.2 Names.First Names.Last
Note that Complex Variables are not arrays.
The variable name, the "STEM", ends at the first period.
Everything after the first period is the "TAIL". The TAIL can take on any value.
| + - \< | plus, minus, not |
| ** | raise to a power |
| * / // % | multiply, divide, remainder, integer divide |
| + - | add, subtract |
| || | concatenate (abuttal) |
| = \= > < \< \> >= <= <> >< | normal comparison |
| == \== >> << \>> << >>= <<= | strict comparison |
| & | && | and, or, exclusive or |
/* Simple Statements */
A = 3
B = "Three"
c = 3 + 4.5
d = "String" || "s"
SAY A+5 B C
-->8 Three 7.5
SAY A || B || C
-->3Three7.5
SAY A || ";" || B
-->3;Three
SAY A || ";" B
-->3; Three
SAY D
-->Strings
There is a difference between concatenate (||) and abut
Slightly more complex statements:
C = ( A + B ) ** 2 i = 2 Lookup.1 = "First" Lookup.2 = "Second" Lookup.3 = "Third" Lookup.4 = "Fourth" Lookup.5 = "Fifth" SAY Lookup.i + 3
(By convention Lookup.0 would contain 5, indicating how many items have been defined for the stem "Lookup" Note that this only a convention, not an automatic REXX system feature.)
The following code snip, using complex variables, is valid:
name = "John Smith" address.name = "123 Elm Street" name = "Joe Smith" address.name = "45 Main Street"
test = function_name( [expression] [, [expression]] ) call function_name [expression] [, [expression]]
/* Conditional Statements */
IF ( A = B ) THEN SAY 'Equal'
ELSE SAY "unequal"
IF ( A = B) THEN DO
SAY "equal"
.
.
.
END
ELSE DO
SAY "unequal"
.
.
.
END
SELECT
WHEN ( x = 1 ) THEN SAY "x is one"
WHEN ( x = 2 ) THEN SAY "x is two"
WHEN ( x = 3 ) THEN SAY "x is" x
OTHERWISE SAY "Why did you enter" x || "?"
END
/* Loops */
DO I=1 TO 6 BY 1
Y = Y + 1
END I
DO I=1 TO 7 WHILE ( X < 10 )
x = X + 1
END /* I */
DO 10
x = x + 1
END
DO FOREVER
x = x + 1
IF ( x > 10 ) THEN LEAVE
END
Rexx Group Charter
Lesson 1 | Lesson 2 | Lesson 3 | Lesson 4
Exercises 1 | Exercises 2 | Exercises 3
Answers to exercises
Exercises 1
Example code
Stock Market | Stock Market_a
About these pages | Page building by: | Content updated 07-09-2005 08:12am |