Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Want to put in a loop in EVALUATE
Goto page Previous  1, 2
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
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...


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

http://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: 684
Location: Whitby, ON, Canada

PostPosted: Fri Apr 13, 2012 5:22 pm    Post subject:
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: 8491
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 13, 2012 5:27 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7312

PostPosted: Fri Apr 13, 2012 5:30 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
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: 8491
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 13, 2012 5:34 pm    Post subject:
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.    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need to loop & extract from varia... pkmurali CLIST & REXX 2 Thu Jan 10, 2019 11:42 pm
No new posts save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am
No new posts print out the correct info in LOOP? jackzhang75 CLIST & REXX 7 Wed Dec 23, 2015 10:39 pm
No new posts Using different values for Skeleton d... venksiv CLIST & REXX 8 Thu Sep 03, 2015 5:28 pm
No new posts Issue with Do Loop. santosh_g CLIST & REXX 5 Tue May 12, 2015 9:24 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us