Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is NEXT SENTENCE?

NEXT SENTENCE vs CONTINUE

What is NEXT SENTENCE?

by  k5tm  Posted    (Edited  )
A COBOL paragraph contains one (actually zero) or more sentences. A sentence is a series of statements terminated by a period (a.k.a. full stop). A statement starts with a verb (i.e. MOVE, ADD, STOP, IF) and may contain one or more clauses.

NEXT SENTENCE is similar to a statement that is essentially a GO TO. NEXT SENTENCE causes the transfer of control (i.e. a GO TO) to the statement following the period (full stop) that terminates the sentence containing the NEXT SENTENCE.
Code:
IF A = B 
   NEXT SENTENCE
ELSE
   MOVE C to D
END-IF
DISPLAY "This is NOT the NEXT SENTENCE".

DISPLAY "This IS the NEXT SENTENCE".
In this example, if A equals B then the next statement to be executed after NEXT SENTENCE will be
Code:
DISPLAY "This IS the NEXT SENTENCE",
since this is the first statement after the period terminating the sentence containing the NEXT SENTENCE.

Note: This example does not conform to the ANSI/ISO standard for NEXT SENTENCE, so your compiler may properly complain about the syntax. However, the example does serve to illustrate the point.

Note: NEXT SENTENCE is not a real statement because it may be used only within other specific statements, most notably the IF statement. Here again, though, some vendors allow a NEXT SENTENCE statement as a nonstandard extension.

[sup]Thanks to Bill Klein for corrections regarding standard COBOL.[/sup]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top