Custom Search

why we use perform in cobol,perform verb is one of the most important in cobol,the simple form of the perform verb

What Is the PERFORM Verb?
A program that executes from beginning to end and then stops might be useful for something, but it wouldn't do much more than the examples already covered. Suppose you had one action that you performed several times in a program. In top-to-bottom execution, you would have to code that same logic over and over.
The PERFORM verb avoids this problem of coding repetitive actions. In order to illustrate the effect of a PERFORM, Listing 3.6 uses another version of the "Hello world" program. A PERFORM is a kind of "jump" with a "bounce back."
TYPE: Listing 3.6. Using PERFORM.
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLO04.
000300
000400* This program illustrates the use of a PERFORM
000500
000600 ENVIRONMENT DIVISION.
000700 DATA DIVISION.
000800 PROCEDURE DIVISION.
000900
001000 PROGRAM-BEGIN.
001100 DISPLAY "Today's message is:".
001200 PERFORM SAY-HELLO.
001300
001400 PROGRAM-DONE.
001500 STOP RUN.
001600
001700 SAY-HELLO.
001800 DISPLAY "Hello world".
001900
OUTPUT:
Today's message is:
Hello world
C>
C>
ANALYSIS: At line 001200, PERFORM SAY-HELLO indicates the following:
1. Locate the paragraph named SAY-HELLO.

2. Jump to that paragraph and start executing there.

3. When that paragraph ends, return to the end of this sentence (PERFORM SAY-HELLO).