[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnubol: "Illegal" Next Sentence



The topic of "illegal" Next Sentence (i.e. a Next Sentence in an IF with an
END-IF or a SEARCH with an END-SEARCH) is one of those areas that gets into
"religious wars" among COBOL people.

I'll start with a warning, I happen to be on the side for ALLOWING "NEXT
SENTENCE" in constructs with scope-terminators.  This was (explicitly)
allowed in the JOD; is allowed as a documented (and flagged) extension by
Micro Focus, IBM, and a variety of other vendors.

Having said that, the entire "NEXT SENTENCE" construct is being put into the
(new) category called "archaic" in the draft Standard, and I do fully
understand that it is error-prone (at least when you don't understand how
DIFFERENT "continue" and "next sentence" are).  Therefore, if you all are
going to be "legalistic" and enforce the ANSI rule on it, I won't fight too
hard for the extension.

I do want to point out one thing about "illegal" next sentences - that you
may not realize (but which was confirmed by a J4 interpretation request).  If
you really WANT to use "Next Sentence *logic*" you can in every conforming
implementation.  All you need to do is:

A) Create a variable in Working-Storage (that you never modify in your
procedure division - i.e. a constant)

  01 Next-Sentence Pic X Value Space.

B) Create a COPY member called NextSentence which has the following code in
it:

  If Next-Sentence = Space
    If Next-Sentence = Space
        Next Sentence
    Else
        Continue
  Else
     Continue
  End-IF

   ***

That copy member can be copied into any place in your Procedure Division
(even in an IF with an END-IF - or a SEARCH with an END-SEARCH) and create
absolutely conforming source code - that does a NEXT SENTENCE. (Let me know
if you need "chapter and verse" on why it is conforming - but it is.)

Bottom-Line:
  My suggestion (but I won't fight too hard for it) is to just let a NEXT
SENTENCE be used whether or not the construct has a scope terminator.

Bill Klein
  wmklein <at> ix.netcom.com


--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.