Saturday, September 5, 2009

PROCEDURE DIVISION


The PROCEDURE DIVISION consists of a series of procedures called paragraphs, each designed to perform a specific function. A paragraph consists of a paragraph name coded in Area A and a series of procedural statements designed to perform a desired function coded in Area B. Procedures frequently execute other procedures as indicated in the following example:


0000-MAIN-DRIVER.


PERFORM 1000-INITIALIZATION-ROUTINE.


PERFORM 2000-MAIN-PROCESSING


UNTIL END-OF-FILE.


PERFORM 3000-FINALIZE-ROUTINE.


STOP RUN.


Notice the use of punctuation in the preceding paragraph. Each statement should be a sentence, that is, it should end with a period unless it is part of a conditional sentence. Sentences which are continued across multiple lines should be indented on the succeeding lines. Phrases which modify the behavior of a statement such as UNTIL in the PERFORM statement should be coded on a new line so that they stand out. For more tips on making your code easy to follow, see Style.