Skip to content
COBOL

EVALUATE

COBOL's multi-way decision statement, and a clearer alternative to a long chain of nested IFs.

Also written EVALUATE WHEN, case statement

EVALUATE tests a value against a series of possibilities and runs the branch that matches. It is COBOL's equivalent of a case or switch statement, and it is the readable way to express business rules with several outcomes.

The structure is straightforward: state what is being evaluated, then list WHEN clauses giving the values to match and what to do for each, with WHEN OTHER catching everything unmatched. Ranges and combinations of conditions are supported, so a rule such as one band of values behaving differently from another is expressed directly.

It also has a form that evaluates several values at once, which is how decision tables are written: a grid of conditions and the action for each combination. Business rules often arrive from the business in exactly that shape, and being able to write them that way keeps the code close to the specification.

Compared with deeply nested IF statements, which older code is full of, EVALUATE is far easier to read and much harder to get wrong when a new case is added later.

Browse all 115 terms

Learn this properly.

Use EVALUATE for real in Mainframe101, in your browser, with Zed beside you. Join the waitlist.

Early access and updates. No spam, unsubscribe any time.