Showing posts with label CONTINUE. Show all posts
Showing posts with label CONTINUE. Show all posts

Wednesday, December 10, 2008

What is the difference between NEXT SENTENCE and CONTINUE ?

NEXT SENTENCE gives control to the statement following the next period.

CONTINUE gives control to the next (imperative) verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.

Example :
IF A > C
IF A > B
CONTINUE
ELSE
MOVE WS-A TO WS-B
END-IF
MOVE WS-C TO WS-B
END-IF.
MOVE WS-B TO WS-A

In the above example , once the CONTINUE is executed the control will be transfered to next imperative executable statement ( MOVE WS-C TO WS-B).

Whereas, If we use NEXT SENTENCE instead of CONTINUE then control gets transferred to the statement following the next Period (MOVE WS-B TO WS-A).

Hope this helps.
Please do comment if you have any further questions on this.