Skip to Main Content
PROGRAMMING IN COBOL/400: 2nd Edition
book

PROGRAMMING IN COBOL/400: 2nd Edition

by James Cooper, Nancy Stern, Robert A. Stern
January 2002
Intermediate to advanced content levelIntermediate to advanced
736 pages
18h 57m
English
Wiley
Content preview from PROGRAMMING IN COBOL/400: 2nd Edition

Chapter 8. DECISION-MAKING USING THE IF AND EVALUATE STATEMENTS

CHAPTER OBJECTIVES

Upon completion of this chapter, you should be able to

  • Explain how numeric and alphanumeric fields are compared.

  • Describe the rules for forming numeric and alphanumeric literals.

  • Describe and demonstrate the use of the various IF statements.

  • Describe and demonstrate the use of the EVALUATE statement.

LOGICAL CONTROL STRUCTURES

In this chapter we focus on some instructions that enable the program 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

  1. Sequence.

  2. Selection (IF-THEN-ELSE).

  3. Iteration (PERFORM).

  4. Case (EVALUATE).

In this chapter, we focus first on the IF-THEN-ELSE structure that permits programs to execute one or more instructions depending on the contents of fields. Then, we present the case structure, which is executed using the EVALUATE verb. In the next chapter, we consider iteration in detail, focusing on the PERFORM statement and its options.

THE IF CONDITIONAL STATEMENT

A conditional statement performs operations depending on the existence of some condition. Such statements generally begin with the word IF and are called IF-THEN-ELSE or selection structures.

THE INSTRUCTION FORMAT FOR AN IF STATEMENT

The basic instruction format for IF statements is

Instruction Format

THEN is Optional. The THEN clause in the instruction ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Designing and Programming CICS Applications

Designing and Programming CICS Applications

John Horswill, Members of the CICS Development Team at IBM Hursley

Publisher Resources

ISBN: 9780471418467Purchase book