View previous topic :: View next topic
|
Author |
Message |
vivek_mvs1
New User
Joined: 25 Apr 2006 Posts: 12
|
|
|
|
Hi,
i would like to know about PERFORM statement in COBOL.
I want to know the diff between PERFORM and PERFORM-THRU,and how the controls are passed in both.
For eg:
PERFORM L-1
-----------
-----------
L-1.
--------
--------
EXIT.
L-2.
-------
-------
Will the control be passed back the to statements after PERFORM,before L-2 is executed? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yes, as long as L-1 logic does not branch anywhere else. |
|
Back to top |
|
|
krishna_sureka
New User
Joined: 05 Sep 2006 Posts: 7 Location: Pune
|
|
|
|
Different forms of Perform:
1. Simple PERFORM
PERFORM Paragraph-Name.
(In this case the execution returns to the statement after the perform statemetnt once the para is executed.)
2. In-line PERFORM
PERFORM
logic
END-PERFORM
3. PERFORM . . . THRU
PERFORM C1000-BEGIN-CALC-PARA THRU C5000-END-CALC-PARA
(In this case the execution starts with the first statement in C1000-BEGIN-CALC-PARA and ends with the last statement of C5000-END-CALC-PARA)
4. PERFORM . . . UNTIL
PERFORM Paragraph-Name-1 UNTIL condition
5. PERFORM . . . TIMES
PERFORM Paragraph-Name-1 integer TIMES.
6. PERFORM . . . VARYING
PERFORM Paragraph-Name-1 [ { THRU, THROUGH }Paragraph-Name-2 ] VARYING identifier-1 FROM
{identifier-2, integer-1} BY { identifier-3, integer-2 }
UNTIL condition.
Eg.
PERFORM 500-WRITE-PARA VARYING I FROM 1 BY 1 UNTIL I > 5.
Let me know if more explanation required on any of the above way of using PERFORM. |
|
Back to top |
|
|
DeepaBala
New User
Joined: 20 Feb 2007 Posts: 13 Location: Trivandrum
|
|
|
|
Hi Friends,
I have one doubt. plz clear that.
I want to Know What is the Difference b/w Perform with after and prform with before...
plz give some examples for easy understanding |
|
Back to top |
|
|
krishna_sureka
New User
Joined: 05 Sep 2006 Posts: 7 Location: Pune
|
|
|
|
If the TEST BEFORE phrase is specified, the condition is tested before any statements are executed and if the TEST AFTER phrase is specified, the statements to be performed are executed at least once before the condition is tested
Format: PERFORM procedure-name-1 [{THRU, THROUGH} procedure-name-2] UNTIL condition
[WITH TEST {AFTER, BEFORE}].
Examples:
Assume that EOF is already set to "Y"
1. TEST AFTER:
PERFORM READ-PARA UNTIL EOF = ?Y? WITH TEST AFTER.
Now even though the EOF is already "Y", READ-PARA will be executed once and then condition will be checked later.
2. TEST BEFORE
PERFORM READ-PARA UNTIL EOF = ?Y? WITH TEST BEFORE.
In this case the condition is checked before any statement is executed so as EOF is already "Y", READ-PARA will not be executed even one time also. |
|
Back to top |
|
|
DeepaBala
New User
Joined: 20 Feb 2007 Posts: 13 Location: Trivandrum
|
|
|
|
Thanks for the information |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
DeepaBala wrote: |
Hi Friends,
I have one doubt. plz clear that.
I want to Know What is the Difference b/w Perform with after and prform with before...
plz give some examples for easy understanding |
ANSWER;
MOSTLY THIS TERM IS COMES ACROSS WHEN YOU USE MULTIDIMENTION TABLE
I GIVE YOU EXAMPLE
SUPPOSE IN ONE SHCOOL/CLASS THERE ARE STUDENTS AND E THEY HAVE 5 SUBJECTS EACH SO I WANT TO MAKE TABLE FOR THIS THEN
SO I SEE YOU STRUCTURE
STUDENT 1. HARISH HIS 5 SUBJECTS 1.VVV
2.YYY
3.TTT
4.YYY
.HHH
2.SACHIN 1.VVV
2.YYY
3.TTT
4.YYY
5.HHH
SO I WANT TO MAKE TABLE FOR THIS
THEN PROGRAME IS
ID DIVISION.
PROGRAM-ID.
WORKING-STORAGE SECTION.
O1 CLASS
02 STUDEN-NAME PIC X(10) OCCURES 10 TIMES INDEXED BY I.
O2 SUBJECTS PIC X(3) OCCURS 5 TIMES INDEXED BY J.
PROCEDURE DIVISION.
ACCEPT I.
PERFORM WITH VARYING BEFORE I FROM 1 BY 1 UNTIL I >10
ACCEPT J
PERFORM WITH TEST AFTER J FROM 1 BY 1 UNTIL J>5
DISPLAY I , J.
STOP RUN. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
sachin,
Try at least to use the correct syntax in your examples.... |
|
Back to top |
|
|
|