View previous topic :: View next topic
|
Author |
Message |
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
Need a clarification on coding Perform PARA Vs Perform Para Thru Exit-Para.
In our shop, the usual standard to call a Para is as below. This code will call Para 1000-PARA and execute until 1000-EXIT and the control returns to the next statement of PERFORM.
Code: |
PERFORM 1000-PARA THRU 1000-EXIT.
.
.
.
1000-PARA.
Code within Para.
1000-EXIT.
EXIT.
|
My doubt is, there was a code as below. Need to know how the control flows in this case.
Code: |
PERFORM 1000-PARA.
.
.
1000-PARA.
Code within Para.
2000-PARA.
Code within Para. |
Please clarify, let me know for more detail. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The code within 1000-PARA will be executed, after which control returns to the statement after the PERFORM -- the code in 2000-PARA will not be executed via the PERFORM. However, if control falls into 1000-PARA without being executed via a PERFORM, the code in 2000-PARA would be executed since sequential flow control would ensue. |
|
Back to top |
|
|
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
Thanks for clarifying Bob. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Each shop has its own standards. One "gotcha" to be aware of is when copying a paragraph and its exit to another area of the source and modifying the paragraph names, some people forget to change the exit paragraph name also. Can't tell you how many times this has happened to others (and myself on occasion ). In other words try performing 2000-NEW-PARAGRAPH THRU 1000-EXIT sometime and watch what happens! |
|
Back to top |
|
|
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
Ok Terry
actually my doubt was to check what will happen when PERFORM 1000-PARA is executed where 1000-PARA doesn't have any EXIT, I think Robert Sample explained that clearly saying the control will return back after the PERFORM Statement once all the code with in 1000-PARA is executed,it doesn't goto 2000-PARA. |
|
Back to top |
|
|
sundar28
New User
Joined: 30 Jul 2005 Posts: 11 Location: Mysore
|
|
|
|
The difference is the convention of having a name for the end of each para.
In structured programming, GOTO is forbidden. It is permitted to transfer the control to the end of current para alone. To achieve this, a name for the end of the para is needed.
When we reuse the portions of existing code into our new code we can achieve structured logic by constraining all GOTOs to their respective exit para. The code would still be structured and with little changes.
The above facts are my perceptions with my experience; please correct me if they are not precise. |
|
Back to top |
|
|
|