Chapter 8. Decision Making Using the IF and EVALUATE Statements
To familiarize you with
The use of
IFstatements for selection.
The variety of formats and options available with the conditional statement.
The use of the
SELECTION USING A SIMPLE IF STATEMENT
A Review Of Logical Control Structures
Thus far we have learned the syntax rules for numerous COBOL instructions. The pseudocode and flowchart excerpts for executing a sequence of instructions are as follows:
But a sequence is only one method for executing instructions. In this chapter we will focus on some instructions that enable the computer to make decisions that affect the order in which statements are executed. Such instructions are referred to as logical control structures.
The full range of logical control structures used in any program, regardless of the programming language, is as follows:
In this chapter we focus first on the IF-THEN-ELSE structure, which permits us to execute one or more instructions depending on the contents of fields. The IF-THEN-ELSE structure is coded in COBOL with the
IF statement. Then we focus on the case structure, which is coded with the
EVALUATE verb. In the next chapter, we will consider iteration in detail, focusing on the
PERFORM statement and its options.