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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SECTION performing itself 1

Status
Not open for further replies.

MKuiper

Programmer
Jan 29, 2002
364
NL
Please, experts, take a look at the little program below. The question is simple: Is it legal for a section performing it self ??
It runs fine using Net Express 3.1, but Fujitsu Cobol version 6 is getting completely mad if more than two times "Y" is answered.
Is it a bug in Fujitsu or a "feature" from Net Express??

Code:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. XXX.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01  VELD1    PIC 9(09) VALUE 0.
       01  ONCEMORE PIC X.

       PROCEDURE DIVISION.
       MAIN SECTION.
       M1.
           PERFORM R010.
           STOP RUN.
       M9.
           EXIT.

       R010 SECTION.
       R01001.
           ADD 1 TO VELD1.
           DISPLAY VELD1 " --- Again ??".
           ACCEPT ONCEMORE.
           IF  FUNCTION UPPER-CASE (ONCEMORE) = "Y"
               PERFORM R010.
           SUBTRACT 1 FROM VELD1.
           DISPLAY VELD1.
       R01099.
           EXIT.


Marcel
 
This program does not comply with the 1985 COBOL standard and therefore its behavior is undetermined. Some vendors have implemented recursive behavior for PERFORM, but it is not standard.

Tom Morrison
 
Thank you Tom for making this clear. Could you post the rule it does not comply with, just for my knowledge?


Marcel
 
ISO 1989-1985/ANSI X3.23-1985
6.21 THE PERFORM STATEMENT
6.21.4 General Rules
(14) If the range of a PERFORM statement includes another PERFORM statement, the sequence of procedures associated with the included PERFORM must itself either be totally included in, or totally excluded from, the logical sequence referred to by the first PERFORM. Thus, an active PERFORM statement, whose execution point begins within the range of another active PERFORM statement, must not allow control to pass to the exit of the other active PERFORM statement; furthermore, two or more such active PERFORM statements may not have a common exit. ...

(Emphasis added.)

Tom Morrison
 
Also relevant (as far as wording goes) from the online Micro Focus NetExpress documentation, they include an EXPLICIT extension to the ANSI/ISO Standard - worded as follows:

From:

"These restrictions are not enforced. PERFORM statements can be freely nested, and recursion (a PERFORM statement performing a procedure containing it) is allowed. Only the exit point of the innermost PERFORM statement currently being executed is recognized. These rules can be changed by use of the PERFORM-TYPE Compiler directive."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top