COBOLbeginner
EVALUATE Statement
Use EVALUATE as COBOL's structured multi-branch decision construct, equivalent to switch/case but far more flexible.
EVALUATE is COBOL's answer to nested IF-THEN-ELSE chains that become unreadable past two or three conditions. It's frequently the first thing interviewers point to when asking you to modernize or clean up legacy code, because badly nested IFs are extremely common in decades-old COBOL and EVALUATE is the idiomatic fix.
EVALUATE is a restaurant host checking a series of yes/no questions in order — party size, reservation, walk-in — and seating you at the first matching table type instead of asking you fifteen separate nested questions.
Key Concepts
1
At its simplest, EVALUATE TRUE acts like a switch statement, testing a series of WHEN conditions top to bottom and executing the first match, with WHEN OTHER as the default/fallback branch. Unlike a plain switch in C-family languages, EVALUATE conditions aren't limited to equality against one variable — each WHEN can test a completely different condition, since the subject being evaluated is often the literal value TRUE.
2
EVALUATE also supports evaluating multiple subjects at once by separating them with ALSO, testing combinations of conditions in one construct rather than nesting several IFs — useful for decision-table-style logic such as combined status and type codes. It also accepts range conditions (THRU) and the ANY keyword to mean 'don't care' for a given position.
3
Interviewers often present a nested IF and ask you to rewrite it with EVALUATE, checking whether you understand both the readability win and the subtle behavioral difference: EVALUATE always tests WHEN clauses in order and stops at the first true one, just like a well-formed IF-ELSE chain, so there's no fallthrough behavior to worry about like in C's switch.