typestar

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

  1. MAIN-PARA runs first and calls the other two by name.
  2. PERFORM BREW-TEA jumps to the paragraph, runs it, and comes back.
  3. Each paragraph is just a name ending in a period, statements after it.

Keywords and builtins used here

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.

Type this snippet

Step 3 of 3 in Loops, step 18 of 27 in Language basics.

← Previous Next →