IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Want to put in a loop in EVALUATE


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
coboljoost

New User


Joined: 05 Apr 2012
Posts: 5
Location: groningen

PostPosted: Fri Apr 13, 2012 5:05 pm
Reply with quote

Bill Woodger wrote:
coboljoost wrote:
[...]
as robert stated, when not using the exit statement the possibility exist for falling through the perform exit paragraph (especially so when using goto's).

What Robert actually wrote:
If a program contains GO TO and PERFORM statements, the possibility exists for falling through PERFORM EXIT paragraphs. In fact, a poorly written program can even fall through PERFORM EXIT paragraphs without a single GO TO statement in it -- we've seen examples on this forum.


Quite a different thing.

Quote:
using the "thru ..-exit" will make life easier when debugging.


Can you explain how?

Can you explain, leaving aside all the other stuff, what you think

Code:
    PERFORM A-PARAGRAPH THRU A-PARAGRAPH-EXIT

A-PARAGRAPH.

...

A-PARAGRAPH-EXIT.
    EXIT
    .


does for you? How does it protect you from GO TOs? How does it aid you at all? Leaving out all the rest, just sticking to the subject. You gave it as general advice, best practice, so...


www.robelle.com/smugbook/cobol.html
point 3

www.tonymarston.net/cobol/cobolstandards.html#perform_through

5.7.1 PERFORM <section>
Even though COBOL allows the PERFORM command to be used on paragraphs as well as sections, its use should be limited to sections only. If necessary make the offending paragraph into a self-contained section, or an in-line PERFORM (if it is small enough). This guideline then avoids the possibility that someone may split the paragraph in two, thereby causing the PERFORM to terminate at the new paragraph name.
Please note that if the word SECTION is missed out on a section name it will be treated as a paragraph. As there is usually nothing but comments between the section name and the next paragraph it means that no code will actually be executed by that PERFORM statement. Unfortunately the code WILL be included in the PERFORM of the preceding section. This usually causes lots of confusion.


--------------------------------------------------------------------------------

5.7.2 PERFORM ... THROUGH ...
Avoid the use of PERFORM <procedure-A> THROUGH <procedure-Z>. It is good practice to name each procedure (section) explicitly - this makes it easier to search a source file for all occurrences of PERFORM <sectionname>, and also avoids the possibility that someone may add a new section between existing sections without realising that it now falls within the bounds of the PERFORM <A> THROUGH <C> statement. A program can produce some very peculiar results if a section is `accidentally' performed out of sequence, and is not easy to debug.

--------------------------------------------------------------------------------

5.7.3 The EXIT statement
The EXIT verb in COBOL does not produce an EXIT instruction in the object program - it is ignored, but is maintained for documentation purposes only. Whenever a section is PERFORMed COBOL will generate its own (hidden) EXIT instruction when the next section-name is encountered. If a section-name in your source file has the word SECTION missing, COBOL will treat it as a continuation of the preceding section - this can cause some very peculiar results (refer to PERFORM <section>).

--------------------------------------------------------------------------------

5.7.4 The GO TO statement
Do not use the GO TO verb to transfer control to a point which is outside the current section as any implied EXIT points will be ignored. This means that the program will go where it thinks it should go, which is probably NOT where it is supposed to go.

Guess i am not alone in my opinion on what is best practise am I ?
You seem to stubborn to convince though.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Fri Apr 13, 2012 5:22 pm
Reply with quote

This thread almost makes me nostalgic for COMP.LANG.COBOL, where this sort of discussion can go on for weeks without ever reaching a consensus. icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 13, 2012 5:27 pm
Reply with quote

coboljoost, if those are the standards your site follows, then follow them. Or, if they are the standards YOU want to follow, follow them. However, be aware that what you are quoting is more than 25 years old at this point, and COBOL is a dynamic language that changes over time. Since your link was last updated in 1993, I sincerely doubt it includes much about the COBOL 2002 changes, whether or not the standards are relevant any more. And of course there will be nothing about in-line PERFORM statements in those standards. But don't expect people on this forum, especially those of us with 25 ... 30 ... 35 or more years of COBOL coding experience, to agree with your opinions about what should be standards.

Furthermore, your post made extensive comments about SECTIONS -- which haven't been mentioned before in this thread. I have seen some really strange and difficult-to-debug errors arise from mixing PERFORM sections and PERFORM paragraphs in COBOL programs. Using SECTION names in a PROCEDURE DIVISION imposed an additional hierarchy on a program, a hierarchy that may -- or may not -- be intended.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 13, 2012 5:30 pm
Reply with quote

I'm with you Don :-)

If someone repeatedly can't answer a question and uses the colour red to prove that grass is green, there is little that can usefully be done...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 13, 2012 5:34 pm
Reply with quote

I think Bill and Don are right -- thread is being locked to avoid wasting any more time on pointless discussions about opinions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. REXX - Do - Not able to LOOP CLIST & REXX 10
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts REXX - Dataset checking in a do forev... CLIST & REXX 6
No new posts Need to read duplicate rows from tabl... DB2 3
This topic is locked: you cannot edit posts or make replies. Cobol db2 program going in loop COBOL Programming 4
Search our Forums:

Back to Top