Tuesday, 12 August 2014

NEXT SENTENCE in COBOL and CONTINUE in COBOL [COBOL Tutorial].

CONTINUE in COBOL, COBOL Tutorial, Next Sentence in COBOL
CONTINUE and NEXT STATEMENT in COBOL

Welcome back to today's session on NEXT SENTENCE in COBOL or CONTINUE in COBOL. In this session, you'll learn the basics of COBOL NEXT Sentence and COBOL CONTINUE Statement. You'll also learn how to use NEXT Sentence, COBOL Continue with examples. Let's get started with the NEXT Sentence or COBOL Continue Statement. 

Agenda. 
  • Introduction. 
  • What is the Next Sentence in COBOL?
    • Next Sentence in COBOL Syntax.
    • Next Sentence in COBOL Example. 
  • What is the Continue in COBOL?
    • Continue in COBOL Syntax. 
    • Continue in COBOL Example.
  • COBOL Next Sentence VS COBOL CONTINUE Statement.
  • Summary. 

Introduction. 

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 the 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, COBOL CONTINUE
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. 

COBOL Next Sentence VS COBOL Continue Statement. 

This COBOL Tutorial is associated with a youtube video, that clearly explain the COBOL Next Sentence and COBOL Continue Statement with example. Do watch this video for details understanding. 

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. 



Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

No comments:

Post a comment