COBOL Iterative Programming

COBOL Evaluate verb COBOL Simple Perform

Advertisements


The statements in the program are running in a sequence until or unless if any statement executed in the flow that will alter the execution sequence.

In the program, there might be some need to execute some set of statements in a repetitive/iterative manner. i.e. based on some requirement.

Iterative programming construction involves making the program execution in repetitive manner.

PERFORM statement is the best example for Iterative programming construction.

Let’s discuss about the PERFORM statement.


PERFORM:


PERFORM statement will execute the set of statements/ block of statements repetitively based on condition/literal.

In other words, during the perform execution it transfers the control to set of statements coded under PERFROM.

The same will be repeated until the condition coded in the PERFORM to be TRUE.

PERFORM was mainly classified into two types based on how the statements coded under it.


  1. INLINE PERFORM
  2. OUTLINE PERFORM

Let’s discuss about the difference between the INLINE and OUTLINE Perform below.


InlineOutline
INLINE PERFORM mainly used to perform a set of statements/ block of statements that executed in between the PERFORM and END-PERFORM.OUTLINE PERFORM mainly used to perform set of statements/ block of statements coded in separate section or separate paragraph which are not coded along with PERFORM Statement.
INLINE PERFORM didn’t require any separate PARAGRAPH or SECTION needs to be coded which are to be executed.OUTLINE PERFORM requires a spate PARAGRAPH or SECTION needs to be coded for statements which are to be executed.
Scope terminator (END-PERFORM) is mandatory.Scope terminator (END-PERFORM) was not required.

Inline/Outline PERFORM statement types:


INLINE/OUTLINE PERFORM are divided in to the several types based on the its usage in the program.

Out of those, those are mainly classified into five types.


  • Simple PERFORM.
  • Thru PERFORM.
  • Times PERFORM.
  • Until PERFORM.
  • Varying PERFORM.

SIMPLE PERFORM:

Simple perform is mainly used to execute the large set of statements/block of statements executed separated in different paragraph/section.

Simple PERFORM was categorized to both INLINE/OUTLINED PERFORM.

The Simple PERFORM topic explained in detail here


THROUGH/THRU PERFORM:

THROUGH/THRU PERFORM is mainly used to execute the large set of statements/block of statements executed which are separated with different paragraph/section.

In THROUGH/THRU another paragraph which will act as a end of the performing paragraph.

The THROUGH/THRU PERFORM topic explained in detail here


PERFORM TIMES:

PERFORM TIMES is mainly used to execute the set/block of statements or paragraph/section in repetitively with number of times specified.

PERFORM TIMES requires to execute repetitively up to certain number of times without any specific condition.

The PERFORM TIMES topic explained in detail here


PERFORM UNTIL:

PERFORM UNTIL is mainly used to execute the set/block of statements or paragraph /section until the condition satisfied with UNTIL condition.

PERFORM UNTIL requires to execute repetitively until the specified condition in PERFORM satisfied.

The PERFORM UNTIL topic explained in detail here


PERFORM VARYING:

PERFORM VARYING is mainly used to execute the set/block of statements or paragraph /section repetitively until the specified condition in the perform satisfied.

The literal used in the condition initialized or incremented in the PERFORM itself.

The PERFORM VARYING topic explained in detail here


COBOL Evaluate verb COBOL Simple Perform

Advertisements