CONTINUE vs NEXT SENTENCE

COBOL II introduced the CONTINUE verb, which means "do nothing."

But wait a minute -- isn't that what NEXT SENTENCE means?

No, not quite. NEXT SENTENCE is actually an unconditional branch to whatever follows the next period. In effect, it is a restricted form of GO TO.

Consider the following fragment:

[yuk] [ warning: bad code ahead ]

     IF NOT INPUT-EOF
        IF INPUT-REC-TYPE = '55'
           PERFORM 2100-PROCESS-WTN
        ELSE
           NEXT SENTENCE
        END-IF
        ADD +1 TO INPUT-COUNT.

Quick, now: when INPUT-REC-TYPE is '00', what happens to INPUT-COUNT? Answer: nothing. NEXT SENTENCE branches around the ADD statement.

If you're used to thinking of NEXT SENTENCE as "do nothing," this result may come as a surprise. Before COBOL II, we not only didn't have CONTINUE, we also didn't have END-IF, or any of its kindred. The kind of situation shown above didn't arise.

With COBOL II and its successors, however, these situations can arise. Our old reflexes are no longer reliable.

Conclusions

Do not code NEXT SENTENCE. Ever.

If you really mean "do nothing," code CONTINUE.

If you really mean "branch to the next sentence," code a GO TO, or otherwise rearrange the code. If you insist on a GO TO, code it explicitly -- don't disguise it.


[home]COBOL Home [style forum]COBOL Style Forum