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

PERFORM TIMES, UNTIL and VARYING loops

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

Check fixed iterations (TIMES), pre-test conditionals (UNTIL, while inverse logic), and loops with built-in counter PERFORM VARYING.

What you'll learn in this lesson

  • Repeat blocks or paragraphs for a fixed count via PERFORM N TIMES.
  • Understand the critical difference between while (continue until true) and PERFORM UNTIL (stop when true), as well as WITH TEST BEFORE vs WITH TEST AFTER.
  • Write iterations with integrated automatic counter via PERFORM VARYING ... FROM ... BY ... UNTIL ..., both inline (END-PERFORM) and in paragraph.

Overview

In COBOL the same keyword PERFORM governs both paragraph calls and all numeric, conditional, and incremental index loops.

If you know the exact number of iterations a priori, you can use the inline form (END-PERFORM.) or call an external paragraph:

Sections covered in this lesson

  1. 11. Fixed number cycles (PERFORM TIMES)
  2. 22. Conditional loops (PERFORM UNTIL) and inverted logic
  3. 33. WITH TEST BEFORE (default) vs WITH TEST AFTER (do-while)
  4. 44. Complete cycle PERFORM VARYING ... FROM ... BY ... UNTIL ...
  5. 5Try it yourself
Pro Lesson · Module 3 — Modularity, Paragraphs and Cycles

Unlock "PERFORM TIMES, UNTIL and VARYING loops" and the full Course COBOL curriculum

Check fixed iterations (TIMES), pre-test conditionals (UNTIL, while inverse logic), and loops with built-in counter PERFORM VARYING.

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.