An overview of structured forms
In structured programming theory, only three basic control logic structures are required to program any function:
- Sequences
- Selection
- Iteration.
A sequence is the processing of one function after the other, as shown in Figure 1. No special logic is required because processing is always sequential.
Figure 1. Sequence: Processing Code
Sequentially
A selection is the choice between two or more functions to be processed based on a condition.
For example, the IF macro group, shown in Figure 2, is used for selection.
Figure 2. Selection: Using a
Condition
The CASE macro group, shown in Figure 3, is another example of a macro group used for selection.
Figure 3. Selection: Using a Case Number
An iteration is the repeated processing of the same code while, or until, a condition is true, as shown in Figure 4.
Figure 4. Simple Iteration: The Difference
between DO WHILE and DO UNTIL
- The code can be bypassed (never processed) if condition is false on entry to the DO WHILE loop.
- The code is processed at least once before the DO UNTIL condition is tested.