Skip to main content
Module 3 · Lesson 1 of 25/16 in the course~14 min
Module lessons (1/2)

Paragraphs, PERFORM and Fall-Through

Lesson preview5 hands-on exercises readyCourse COBOL · Module 3 — Modularity, Paragraphs and Cycles

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 with PERFORM.
  • Understand call-and-return semantics (PERFORM always returns to the following statement, unlike GO TO).
  • Prevent the classic fall-through bug by always ending the main stream with STOP RUN. or GOBACK..

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

  1. 11. Anatomy of a Paragraph (Area A vs Area B)
  2. 22. Sequential invocation via PERFORM
  3. 33. The "Fall-Through" bug without STOP RUN.
  4. 44. PERFORM ... THRU and exit paragraphs (EXIT)
  5. 5Try it yourself
Pro Lesson · Module 3 — Modularity, Paragraphs and Cycles

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.