View previous topic :: View next topic
|
Author |
Message |
rulerofera
New User
Joined: 03 Jun 2008 Posts: 30 Location: India
|
|
|
|
While defining a new paragraph in cobol, what are the consequences if SECTION keyword is not used in paragraph name ?
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
A SECTION can contain more than one paragraph. Doing a PERFORM of a SECTION means multiple paragraphs may be executed. Having SECTION names in the PROCEDURE DIVISION is not required.
Way back when a mainframe could have as little as 64K of memory (when I was in school, we ran a 360-30 with 3 partitions with 32K, 20K, and 12K), the SECTION names were numbered and these SECTION numbers were used to define the overlay structure of the program. This allowed swapping of pieces of the program not currently in use out to auxiliary storage so larger programs than would physically fit in memory could be executed. This practice has been obsolete for quite some time since mainframes have more memory these days. |
|
Back to top |
|
|
rulerofera
New User
Joined: 03 Jun 2008 Posts: 30 Location: India
|
|
|
|
Thank You, Robert. That is certainly very well explained.
Just one more thing, though you have already answered, but I was thinking in terms of code fall through. What I mean by this is, if I have a call as PERFORM PARA1 and then PARA1 is followed by PARA2 without any EXIT lines in between and no SECTION keywords, will the control at end of PARA1 fall through the code in PARA2, because EXIT line is not there (in sense usually we have call as PERFORM 100-P1 thru 100-EXIT).
And will the functionality be same in both COBOL and COBOLII compiled programs.
Thanks. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you will find that an exit statement does not do anything.
you perform a para or a sect, execution stops at the next para or section name. If the performing a para, the paragraph with the exit statement is just another paragraph so rookies can 'GO TO' instead of modular coding to avoid 'GO TOs'. |
|
Back to top |
|
|
rulerofera
New User
Joined: 03 Jun 2008 Posts: 30 Location: India
|
|
|
|
Right, Dick.
I tried all the possibilities which I raised earlier. Findings are - code do not fall through, compiled with both COBOL and COBOII program types.
What I did is, I included a para PAR2 immediatley after PARA1 and call only to PARA1. COBOLII compiled with RC = 4 and eleminated uncalled paragraphs. While, COBOL compiled with RC =0 but the control do not fall through PARA2, it executed only PARA1 and finished.
So which means, the only reason to have SECTION keyword is to denote the start of some paragraph; an identifier kind of thing - original purpose lost in history.
Thank You!! - Robert and Dick. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
the only reason to have SECTION keyword is to denote the start of some paragraph |
rulerofera,
you can perform a section - which will execute all paragraphs in that section. (sort of like perform para thru para.) |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Some shops insist on SECTIONS only, some PARAGRAPHS only. It's unwise to have both in the same program. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
It's unwise to have both in the same program |
as i indicated in my earlier post, without the para names in the sections,
they can't write their GO TO's. |
|
Back to top |
|
|
rulerofera
New User
Joined: 03 Jun 2008 Posts: 30 Location: India
|
|
|
|
So it is like, if one uses Go To to call a PARA and if the following para do not have SECTION keyword, then I think the control at end of PARA1 is bound to fall through PARA2 |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
You don't call a paragraph or a section. Section is a COBOL reserved word. When you perform a section you perform from the start of the SECTION upto and including the last statement of the last paragraph before the next section then control returns to the statement after the perform. If you perform a paragraph control returns to the next statement after the perform at the end of the paragraph you are performing.
GO TO and PERFORM are completely different.
Just consider a SECTION as a collection of paragraphs. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi rulerofera,
You could probably have a look into this topic which was discussed some time back. |
|
Back to top |
|
|
|