Kilowatt Software's
Classic Rexx Tutorial
Language Level 4.00 (TRL-2)

1 Expressions

Expressions are used in:

The general form of an expression is one of the following:

1.1 Terms

Expression terms can be one of the following:

Furthermore, wherever a term can appear an expression can appear!

Here is an assignment instruction with an intricate expression:

1.2 Operators

1.2.1 Concatenation operators

Rexx has two fundamental string concatenation operators.

  1. concatenation with an intervening space -- space concatenation

  2. concatenation WITHOUT an intervening space -- abuttal concatenation

Click here for a detailed description of string concatenation operators.

1.2.2 Arithmetic operators

Numeric terms can be processed with the following operators:

1.2.3 Comparison operators

Comparison operators compare two terms. The result of the comparison is '1' when the terms are equal, and '0' otherwise. There are two types of comparison operators -- strict and normal.

In normal comparisons, strings are compared for the length of the shorter term, and trailing spaces are ignored. The collating order of characters is implementation-dependent. There are significant differences between the ordering of characters in Ascii environments, versus EBCDIC.

When both terms in a normal comparison are numeric, then a numeric comparison is performed. '7' is less than '11' in a normal comparison.

In strict comparisons, trailing spaces are significant. Strict comparisons always compare string values, even though both terms are numeric. '7' is greater than '11' in a strict comparison!

1.2.3.1 Normal comparisons

Note: The ¬ operator character may be absent in Ascii implementations. The backslash character (\) is now preferred.

1.2.3.2 Strict comparisons

Strict comparison operators are similar to normal comparison operators, but has doubled operators.

1.2.4 Logical (boolean) operators

Logical operators transform the boolean sense of one or two terms. A term is considered to be false if it is strictly equal to '0'. A term is considered to be true if it is strictly equal to '1'. Any values other than '0' or '1' are invalid, and cause error #34 (logical value not 0 or 1) to be raised.

1.2.5 Boolean expressions

Boolean expressions are used in the condition clauses of IF, DO, and WHEN instructions,

As mentioned above, the result of a boolean expression is considered to be false if it is strictly equal to '0'. A term is considered to be true if it is strictly equal to '1'. Any values other than '0' or '1' are invalid, and cause error #34 (logical value not 0 or 1) to be raised.

Some examples are helpful.


Kilowatt Software's -- Classic Rexx Tutorial -- Back to top
Click here if you have any comments or questions regarding this tutorial

Last updated on: 15 Apr 2003