MainframeMaster

COBOL Tutorial

COBOL TRUE - Quick Reference

Progress0 of 0 lessons

Overview

TRUE is used in conditional logic, most notably in EVALUATE TRUE, to simplify multi-branch decision structures. Support for boolean literals and types varies by compiler.

Common Patterns

  • EVALUATE TRUE - Case-like branching by conditions
  • IF conditions - Standard conditional expressions
  • 88-level flags - Simulated booleans with condition-names

Syntax and Usage

EVALUATE TRUE

cobol
1
2
3
4
5
6
7
8
9
* EVALUATE TRUE for multi-branch logic EVALUATE TRUE WHEN CUSTOMER-AGE < 18 PERFORM MINOR-PROCESSING WHEN CUSTOMER-AGE >= 18 AND CUSTOMER-AGE < 65 PERFORM ADULT-PROCESSING WHEN OTHER PERFORM SENIOR-PROCESSING END-EVALUATE

88-Level Condition Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
* 88-level conditions as booleans 01 FLAGS. 05 PAID-FLAG PIC X VALUE 'N'. 88 PAID VALUE 'Y'. 88 NOT-PAID VALUE 'N'. IF NOT-PAID PERFORM SEND-REMINDER END-IF SET PAID TO TRUE IF PAID PERFORM POST-RECEIPT END-IF

Best Practices

  • Prefer readability - Use EVALUATE TRUE to reduce nesting
  • Use WHEN OTHER - Provide a default branch
  • Avoid overlap - Ensure WHEN conditions are mutually exclusive or ordered
  • Abstract flags - Use 88-levels for clarity when booleans are unavailable

TRUE Quick Reference

AspectDescriptionExample
Multi-branchEVALUATE TRUEWHEN condition-1 ... WHEN OTHER
Flags88-level condition-namesSET cond TO TRUE
PortabilityBoolean support variesUse 88-levels if needed

Test Your Knowledge

1. What does EVALUATE TRUE enable?

  • Arithmetic comparisons only
  • A case-like structure based on conditions that evaluate to true
  • File handling only
  • Screen handling only

2. Which of the following is a valid use of TRUE?

  • As a numeric literal in COMPUTE
  • As a condition in EVALUATE TRUE and IF statements (dialect dependent for boolean types)
  • As a file status value
  • As a PICTURE symbol

3. What is a common replacement when boolean types are not available?

  • Use "YES/NO" or 88-level condition names for flags
  • Use COMP-1 for flags
  • Use REPORT SECTION
  • Use ENVIRONMENT DIVISION

4. What should you avoid in EVALUATE TRUE?

  • Combining multiple WHEN clauses
  • Using overlapping conditions that can both be true
  • Using default WHEN OTHER
  • Using nested EVALUATE

5. What is a best practice for complex conditionals?

  • Prefer deeply nested IFs
  • Use EVALUATE TRUE for clarity and include WHEN OTHER
  • Use GO TO statements
  • Avoid comments and documentation

Frequently Asked Questions