Tuesday, 12 August 2014

NEXT SENTENCE in COBOL and CONTINUE in COBOL.

CONTINUE in COBOL
CONTINUE and NEXT STATEMENT in COBOL

You can code any structured program using three basic structures: the sequence, selection, and iteration structures. Each structure has just one entry point and one exit point, and a program composed of these structures is a proper program. 

Now that you know how to code conditions, you can learn more about the selection and iteration structures that use those conditions. Since the If statement implements the selection structure and the Perform Until implements the iteration structure, you already know how to code the simple forms of these structures. 

In the topics that follow, you’ll see some other coding options such as NEXT SENTENCE in COBOL, CONTINUE in COBOL. So, without wasting time let's start with the tutorial of COBOL NEXT SENTENCE and COBOL CONTINUE verbs.

What is the NEXT SENTENCE in COBOL? 


The NEXT SENTENCE in COBOL simply transfers control to an implicit CONTINUE statement immediately following the next separator period. In case the NEXT SENTENCE in COBOL is specified with END-IF statement, then control does not pass to the statement following the END-IF. However, control passes to the statement after the closest following period.

NEXT SENTENCE in COBOL syntax. 

IF condition-1 THEN
   {statement-1 ...    | NEXT SENTENCE}
.

COBOL NEXT SENTENCE example.

IF SALES-AMOUNT = ZERO
   NEXT SENTENCE
ELSE
   COMPUTE SALES-TAX ROUNDED = SALES-AMOUNT * .0785.

COBOL NEXT SENTENCE
NEXT SENTENCE in COBOL. 

What is the CONTINUE in COBOL?


The CONTINUE in COBOL statement allows you to specify a no operation statement. COBOL CONTINUE statement indicates that no executable instruction is present and control will be transfer control to the next executable instruction after an explicit scope terminator (i.e. END-IF etc.).

CONTINUE in COBOL syntax.

IF condition-1 THEN
   {statement-1 ...    | CONTINUE}
[ELSE {statement-2 ... | CONTINUE}]
[END-IF]

CONTINUE in COBOL example.

IF SALES-AMOUNT = ZERO
   CONTINUE
ELSE
   COMPUTE SALES-TAX ROUNDED = SALES-AMOUNT * .0785
END-IF.


COBOL CONTINUE
CONTINUE in COBOL. 

CONTINUE in COBOL 

Note: In laymen, term both NEXT SENTENCE in COBOL and CONTINUE in COBOL simply transfer control to the next executable statement. 

Important Points regarding the usage of Next Sentence in COBOL and CONTINUE in COBOL. 

  • Don’t use the NEXT SENTENCE if you are using END-IF as the delimiter (and you should). The Use of NEXT SENTENCE causes execution to continue with the next closest period, which is probably the end of the paragraph. 
  • NEXT SENTENCE is prominently used in COBOL 75. However, CONTINUE is used predominately in COBOL 85. 
  • The NEXT SENTENCE / CONTINUE statement can be used anywhere a conditional statement or an imperative-statement can be used. 

Summary.


You also can code the words NEXT SENTENCE in the If or Else portion of an If statement, but we don’t recommend that. When executed, NEXT SENTENCE causes the program to continue with the statement that starts after the period that ends the If statement, which is equivalent to a Go To statement that provides a second exit to the structure. 




No comments:

Post a Comment