Module lessons (1/2)
Paragraphs, PERFORM and Fall-Through
Break the PROCEDURE DIVISION into paragraphs in Area A, recall them sequentially with PERFORM and protect the output with STOP RUN.
What you'll learn in this lesson
- Declare modular paragraphs in Area A (
colonna 8–11) and call them in ordered sequence withPERFORM. - Understand call-and-return semantics (
PERFORMalways returns to the following statement, unlikeGO TO). - Prevent the classic fall-through bug by always ending the main stream with
STOP RUN.orGOBACK..
Overview
In modern languages you break logic into functions or methods; in COBOL you break the PROCEDURE DIVISION into labeled blocks called paragraphs. Unlike functions with local parameters, paragraphs directly share all variables declared in DATA DIVISION.
A paragraph begins obligatorily in Area A (column 8) with the name followed by a period (.), while all the instructions within it are in Area B (column 12+):
Sections covered in this lesson
- 11. Anatomy of a Paragraph (Area A vs Area B)
- 22. Sequential invocation via
PERFORM - 33. The "Fall-Through" bug without
STOP RUN. - 44.
PERFORM ... THRUand exit paragraphs (EXIT) - 5Try it yourself
Unlock "Paragraphs, PERFORM and Fall-Through" and the full Course COBOL curriculum
Break the PROCEDURE DIVISION into paragraphs in Area A, recall them sequentially with PERFORM and protect the output with STOP RUN.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course COBOL plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.