EXECUTE DIVISION: exact behavior?

I am trying to understand the behavior of the COBOL program and I come across the following lines:

PERFORM  525-NUMERIC    THRU  525-EXIT                       
    VARYING K FROM 1  BY 1   UNTIL  K > CAR-L.         

I understand the global concept that it is some kind of cycle based on meaning K, but I do not understand the influence of words THRU 525-EXIT?

+4
source share
3 answers

PERFORM can execute a series of paragraphs or sections sequentially. This is done using THRU / THROUGH to name the last paragraph / SECTION of the series, PERFORM already named the starting point.

Simple version of PERFORM:

       PERFORM                      10-OPEN-INPUT-FILES

This sets the “range” for PERFORM, starting with 10-OPEN-INPUT-FILES and ending with the last instruction in this section.

A PERFORM of several paragraphs, one after another:

       PERFORM                      10-OPEN-INPUT-FILES
         THRU                       10-OPEN-INPUT-FILES-EXIT

PERFORM, 10-OPEN-INPUT-FILES 10-OPEN-INPUT-FILES-EXIT.

, , , , , . , " " , PERFORMed. , , ( , ) .

, . , "-", , , GO TO. , - , - , GO TO, (, , ) - . , "". , , , , ... .

( , ), , PERFORMed PERFORM... THRU... .

, , GO TO, , . exit, PERFORM, , . , , PERFORM, GO TO " ".

, PERFORM... THRU... , ( SECTIONS) PERFORM, ( SECTIONS).

. , SECTION, -/.

. , PERFORM SECTION. PERFORM... THRU... THRU... . , PERFORM... THRU... , , GO TO, , SECTION , . ( ), , - . GO TO - , . GO TO SECTION "" ( , , , ).

PERFORMed , THRU. , ( EXIT /). , . PERFOR, PERFORM.

, EXIT . " " NOP ( NOOP). , PERFORMed, , ( ) EXIT.

, 1985 , EXIT . . EXIT (, 20), DISPLAY. , DISPLAY.

, THRU, GO TO. , GO TO. , .

, GO TO, PERFORM... THRU... . , GO TO, PERFORM... THRU... PERFORM SECTION - GO TO. - GO TO, , GO TO - . GO GO , GO TO, .

, 2014 , EXIT. ( EXIT EXIT PROGRAM , IBM GOBACK, , CALLing).

EXIT PARAGRAPH EXIT SECTION. , , EXIT . EXIT , EXIT, .

EXIT PARAGRAPH EXIT SECTION, , , ( "" ) GO TO, GO TO, EXIT somevariant. , ( EXIT PROGRAM) GO TO, ( ), GO TO.

GO, . GO TO ( THRU), , GO TO, .

, GO TO , , , . , , , , , GO TO rote. , GO TO, GO TO, , .

, , COBOL , GO TO. , " ", - GO TO .

VARYING PERFORM - . , THRU.


, GO TO, PERFORM, : https://codegolf.stackexchange.com/a/20889/16411. , PERFORM... TRHU...


.

+12

.

         Perform Proc-A thru Proc-D.
         ...

     Proc-A. 
        ....

     Proc-B.
        ....

     Proc-C.
        ....

     Proc-D.
        ....

Proc-A thru Proc-D Proc-A, Proc-B, Proc-C Proc-D.

     Perform Proc-A
     Perform Proc-B
     Perform Proc-C
     Perform Proc-D

Thru :

  • , .

     Perform B100-Load-From-DB thru B500-Save-To-Db
    

    ,

     Perform B100-Load-From-DB
     Perform B200-Adjust-Stock-for-Purchases
     Perform B300-Adjust-Stock-for-Sales
     Perform B400-Calculate-Markdowns
     Perform B500-Save-To-Db
    
  • , , ,

     Proc-B.
        ....
    
     Proc-in-wrong-position.
        ....
    
     Proc-C.
        ....
    

, , ,

Cobol, , ; !!!

+11

.

.

    Perform B100-Load-From-DB thru B500-Save-To-Db
...
B100-Load-From-DB
...
B200-Adjust-Stock-for-Purchases
...
B300-Adjust-Stock-for-Sales
...
Some-Danged-Ol-Thing
...
B400-Calculate-Markdowns
...
B500-Save-To-Db

. : B100-Load-From-DB, B200-Adjust-Stock-for-Purchases, B300-Adjust-Stock-for-Sales, Some-Danged-Ol-Thing, B400- Calculate-Markdowns, B500-Save-To-Db

, GO TO PERFORM... THRU .

    Perform B100-Load-From-DB thru B500-Save-To-Db
...
B100-Load-From-DB
...
    GO TO B400-Calculate-Markdowns
...
B200-Adjust-Stock-for-Purchases
...
B300-Adjust-Stock-for-Sales
...
    GO TO B200-Adjust-Stock-for-Purchases
...
Some-Danged-Ol-Thing
...
B400-Calculate-Markdowns
...
B500-Save-To-Db

" ", - PERFORM... THRU.

    Perform B200-Adjust-Stock-for-Purchases thru B300-Adjust-Stock-for-Sales
...
    Perform B100-Load-From-DB thru B200-Adjust-Stock-for-Purchases
...
    Perform B100-Load-From-DB thru Some-Danged-Ol-Thing

. . , .

While I was growing up, I mean to learn how to code in COBOL, I was almost threatened with beating a big man with a rattan stick if I get out of order. Thus, I know how to walk along the edge of the abyss and use PERFORM ... THRU with GO TO interspersed everywhere and not fall from the edge of the world. However, this leads to a very dangerous code that can kill, so, more importantly, I know how to do it and turn it into something civilized.

+5
source

All Articles