On 1 Oct 2013 08:01:35 -0700, in bit.listserv.ibm-main you wrote:

>On Tue, 1 Oct 2013 11:52:16 -0300, Clark Morris wrote:
>>
>>>greatest value of GOTO is the longjump; the ability to exit a
>>>nest of not only compounds, but also blocks and function calls.
>>>I pine for this facility in Rexx, POSIX shell, and C.
>> 
>>IBM COBOL has EXIT PROGRAM and GOBACK both of which can be used with
>>nested programs.  The 2002 COBOL standard has EXIT PERFORM CYCLE and
>>EXIT PERFORM for PERFORM loops, EXIT PARAGRAPH and EXIT SECTION.

In the following example EXIT PERFORM exits the PERFORM loop and goes
to the statement after the END-PERFROM.

EXIT PERFORM CYCLE exits current iteration and goes back to increment
X.

EXIT PARAGRAPH exits the paragraph which contains the PERFORM.

EXIT SECTION exits the section which contains the paragraph which
contains the PERFROM.

This is in the 2002 standard but NOT in current z Series COBOL.

EXIT PROGRAM will exit a nested or called program but not a main
(invoked by JCL) program.

PERFORM VARYING X FROM 1 BY 1 UNTIL X = 10
  some code
  IF A-CONDITION 
    EXIT PERFORM
  END-IF
  IF B-CONDITION 
    EXIT PERFORM CYCLE
  END-IF
  IF C-CONDITION
    EXIT PARAGRAPH
  END-IF
  IF D-CONDITION 
    EXIT SECTION
  END-IF
END-PERFORM      

Clark Morris
>> 
>Can each of these name the CYCLE, PERFORM, PARAGRAPH, or SECTION
>to be EXITed in case of nesting?  (C and POSIX shell have "continue",
>"break", and "return", but these apply only to the innermost loop or call.)
>
>Do these work alike from a separate translation unit?
>
>-- gil
>
>----------------------------------------------------------------------
>For IBM-MAIN subscribe / signoff / archive access instructions,
>send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to