Kilowatt Software L.L.C.
Classic Rexx Tutorial
Language Level 4.00 (TRL-2)

Instruction terminators

There are two ways to conclude an instruction. An instruction is implicitly considered to be complete when the end of a source line is encountered, unless the line was continued. Alternatively, an instruction can be explicitly terminated by a semicolon. This allows a source line to contain multiple instructions, but this practice is discouraged.

Semicolons are generally never necessary in Rexx programs, because the end of source lines automatically terminates instructions. There is one principal exception. When an else clause is on the same source line of an if instruction's then clause, then a semicolon is required to mark the conclusion of the instruction following the then keyword. For example,

The correct form of the if instruction has a semicolon prior to the elsekeyword:

However, it is highly recommended that you structure the logic as follows:

Semicolons are necessary to divide instructions that are processed by an interpret instruction. Similarly, semicolons divide instructions that are entered at an interactive trace prompt.

Other programming languages use isolated semicolons as empty instructions. In Rexx programs, isolated semicolons are not empty instructions. The NOP instruction is explicitly used for this purpose instead. For example, the following program is erroneous:

The correct way to program this in Rexx uses the NOP instruction instead.

You might have seen Rexx programs that have multiple assignment instructions on a single line, especially in books. Your programs will be easier to understand if the assignments are placed on separate lines. Consider the following example.

There is another Rexx idiom for performing multiple assignments. This uses the PARSE instruction. The above assignments can be accomplished as follows:

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

Last updated on: 11 Apr 2006