PERFORM paragraphs in COBOL
Paragraphs are COBOL's subroutines: named blocks that PERFORM visits and returns from.
IDENTIFICATION DIVISION.
PROGRAM-ID. PERFORM-PARAGRAPHS.
PROCEDURE DIVISION.
MAIN-PARA.
*> Paragraphs are named blocks; PERFORM runs one and comes back.
PERFORM BREW-TEA
PERFORM SERVE-TEA
STOP RUN.
BREW-TEA.
DISPLAY "Warm the pot, then three minutes steeping".
SERVE-TEA.
DISPLAY "Milk first is a settled question here".
How it works
MAIN-PARAruns first and calls the other two by name.PERFORM BREW-TEAjumps to the paragraph, runs it, and comes back.- Each paragraph is just a name ending in a period, statements after it.
Keywords and builtins used here
DISPLAYDIVISIONIDENTIFICATIONPERFORMPROCEDURESTOP
The run, in numbers
- Lines
- 12
- Characters to type
- 320
- Tokens
- 30
- Three-star pace
- 45 tpm
At the three-star pace of 45 tokens a minute, this run takes about 40 seconds.
Step 3 of 3 in Loops, step 18 of 27 in Language basics.