Chapter 9. Iteration: Beyond the Basic PERFORM

OBJECTIVES

To familiarize you with

  1. The simple PERFORM.

  2. How PERFORM statements are used for iteration.

  3. The various options available with the PERFORM statement.

THE SIMPLE PERFORM REVIEWED

The Basic Formats

In this section, we will review the simple PERFORM statement, which is used for executing a specified routine from one or more points in a program. This topic was introduced in Chapter 4 but will be discussed in more detail here. Later on in this chapter, we will review how other options of the PERFORM are used for iteration or looping. There are two formats of the basic PERFORM:

1. PERFORM Paragraph-Name

The format for this version of the basic PERFORM is:

Format

PERFORM [paragraph-name-1]

The PERFORM paragraph-name statement will:

  1. Execute all instructions in the named paragraph.

  2. Transfer control to the next instruction in sequence, after the PERFORM paragraph-name.

The Basic Formats

If you look at a reference manual you will find that this format for a PERFORM uses the word "procedure-name" rather than paragraph-name. Because all paragraph-names are also procedure-names, we will use the terms interchangeably for now. In Chapter 14, we will consider procedure-names in more detail.

A simple PERFORM paragraph-name statement is used whenever a series of instructions in a particular paragraph is to be executed from different points in the program. An example of this is ...

Get COBOL for the 21st Century now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.