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

Decisions with IF ed EVALUATE

Lesson preview5 hands-on exercises readyCourse COBOL · Module 2 — Arithmetic and Decisions

Branch the execution with IF-ELSE-END-IF and EVALUATE (multiple values, intervals THRU and EVALUATE TRUE) avoiding truncation from the end point.

What you'll learn in this lesson

  • Write safe branches with IF ... ELSE ... END-IF., avoiding the historical midpoint error.
  • Leverage relational operators and COBOL class tests (IS NUMERIC, AND, OR, NOT).
  • Structure clean multiple choices using EVALUATE on discrete values, THRU intervals, and EVALUATE TRUE compound conditions.

Overview

Conditional checking in COBOL combines readability similar to spoken English with strict rules about scope terminators. Before 1985, a single misplaced point could alter dozens of lines of logic!

The modern canonical form ends each IF with END-IF (without THEN obligatory, although THEN is tolerated):

Sections covered in this lesson

  1. 11. Blocks IF ... ELSE ... END-IF. and the point trap (.)
  2. 22. Relational Operators and Class Tests (IS NUMERIC)
  3. 33. Multiple selection with EVALUATE
  4. 4Try it yourself
Pro Lesson · Module 2 — Arithmetic and Decisions

Unlock "Decisions with IF ed EVALUATE" and the full Course COBOL curriculum

Branch the execution with IF-ELSE-END-IF and EVALUATE (multiple values, intervals THRU and EVALUATE TRUE) avoiding truncation from the end point.

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.