O'Reilly logo

Rexx Programmer's Reference by Howard Fosdick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Control Structures

Overview

Program logic is directed by what are called control structures or constructs — statements like if-then-else, do-while, and the like. Rexx offers a complete set of control structures in less than a dozen instructions.

Rexx fully supports structured programming, a rigorous methodology for program development that simplifies code and reduces programmer error. Structured programming restricts control structures to a handful that permit single points of entry and exit to blocks of code. It encourages modularity and reduces complex spaghetti code to short, readable, sections of self-contained code. Small, well-documented routines mean greater clarity and fewer programmer errors. While developer convenience sometimes leads to unstructured code ("Well... it made sense when I wrote it!"), structured, modular code is more readable and maintainable.

We recommend structured programming; nearly all of the examples in this book are structured. But we note that, as a powerful programming language, Rexx includes instructions that permit unstructured coding if desired.

This chapter discusses how to write structured programs with Rexx. We start by listing the Rexx instructions used to implement structured constructs. Then, we describe each in turn, showing how it is used in the language through numerous code snippets. At appropriate intervals, we present complete sample scripts that illustrate the use of the instructions in structured coding.

The latter part of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required