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

Program flow synopsis

REXX programs are permitted to have an arbitrary control flow structure. Many REXX implementations consider programs that have DO instructions without matching END clauses to be acceptable for execution. Although this may be appropriate for casual programs, this deficiency can give rise to two serious programming pitfalls.

  1. When an END clause is present, but its corresponding DO instruction is absent (as a result of a typographical, commentation, or quotation error) the END clause will be dynamically paired with any preceding unmatched DO instruction. This can cause segments of code to be skipped, with subsequent execution of the instruction after the END with uncertain circumstances.

  2. When the DO instruction is present, but the END clause is absent (due to omission, or typographical error, etc.) the DO instruction will be dynamically paired with any subsequent END clause. This can cause segments of code to be erroneously executed, or skipped.

The RFLOW program can be used to help overcome these pitfalls. It produces a synopsis of a REXX program's control flow. It emits source lines that begin with keywords: IF DO END ELSE SELECT WHEN OTHERWISE ITERATE LEAVE CALL SIGNAL RETURN EXIT THEN. All other source lines are excluded. Lines are emitted according to the nesting level of DO instructions. When an END clause is encountered the nesting level is reduced.

If a DO instruction is absent, a subsequent END clause will have a negative nesting depth. If an END clause is absent, the labels of subsequent procedures will have a positive nesting depth. If an EXIT or RETURN instruction is the last line in your program, it should have a nesting level of 0.

If you write REXX programs that are used in production environments, you can use the RFLOW program to check control flow consistency. The RFLOW program will help you sleep better at night.


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

Last updated on: 8 Oct 2004