COBOL PERFORM Phrase Times - Agenda.
- What is COBOL PERFORM Statements?
- Types of PERFORM in COBOL.
- PERFORM TIMES Phrase in COBOL.
- COBOL PERFORM with TIMES Phrase syntax.
- COBOL PERFORM
- Conclusion.
What is COBOL PERFORM Statements?
In most, programming languages you use the "DO WHILE LOOP" statement to implement looping. However, COBOL is an English-like language, and to implement looping you have to use COBOL PERFORM statement.
PERFORM statement in COBOL is used to transfer control internally to one or more paragraphs/sections. The control will return to the next executable statement after performing the specified paragraphs/sections.
Types of PERFORM in COBOL?
In general, the COBOL PERFORM statement is divided into two categories and has four different formats. These categories are further subdivided into different variants. Let's look at each category one by one. Let's discuss each category briefly:
- An Out-of-line PERFORM statement: The logic or functionality is included in different paragraphs or sections and the branch is set up by using PERFORM statements.
- An in-line PERFORM statement: The logic or functionality is included within the PERFORM and END-PERFORM statement.
As mention earlier, the COBOL PERFORM statement has the following different types:
- PERFORM ..... Paragraph name.
- PERFORM ..... Times phrase.
- PERFORM ..... Thru phrase.
- PERFORM ..... Until phrase.
- PERFORM ..... Varying phrase.
COBOL PERFORM TIMES Phrase (COBOL TIMES phrase PERFORM).
PERFORM... TIMES phrase in COBOL is used to execute the specific paragraph/section for the number of times specified into PERFORM statement.
OR
In general, the COBOL PERFORM TIMES phrase statement tells the computer to execute a sequence of steps, a fixed number of times.
Note: The logic within that paragraph will be executed n times. Refer following example.COBOL PERFORM with TIMES phrase Syntax.
PERFORM [procedure-name]
{identifier | literal} TIMES
[statement-1 ...]
[END-PERFORM].
#1. COBOL PERFORM with TIMES Phrase Example.
*
PROCEDURE DIVISION.
A000-MAIN-PARA.
COBOL PERFORM TIMES Phrase. |
#2. COBOL PERFORM THRU with TIMES Phrase Example.
*
C000-MAIN-PARA.
No comments:
Post a Comment