Modern languages offer a boolean type—true or false in one keyword. Easytrieve predates that style. Instead, boolean logic lives in conditional expressions inside IF, ELSE, END-IF, DO WHILE, and END-DO statements. A condition asks a yes-or-no question: Is SERVICE greater than ten? Is STATUS equal to Y? Is EMPL-NUM NUMERIC? The answer determines whether statements execute or loops continue. Flags in one-byte character fields, bit positions in binary halfwords, and routine result fields like DATEVAL-FLAG YES or NO all play boolean roles without a BOOL letter on DEFINE. Beginners from Java or Python must shift mindset: you do not assign true to a variable—you branch when a comparison succeeds. This page teaches condition types, AND OR evaluation order, flag storage patterns, and how boolean thinking connects to payroll IF blocks in Broadcom training examples.
DEFINE field-length table lists A, M, K, N, P, B, U, and I. None is boolean. You cannot declare ACTIVE-BOOL as type BOOL with values TRUE and FALSE. Instead, define ACTIVE-FLAG as A 1 and compare IF ACTIVE-FLAG EQ Y. Or use N 1 0 with zero meaning false and one meaning true in shop convention. The compiler evaluates conditions at runtime; storage is always another data type underneath.
IF wraps conditional execution. When the condition is true, statements between IF and ELSE or END-IF run. Optional ELSE provides false branch. END-IF closes the block—nesting requires balanced END-IF for each IF. Missing END-IF is a frequent compile error in indented source editors that hide structure.
123456789IF SERVICE GT 14 PERFORM BONUS-CALC END-IF IF SERVICE GT 19 BONUS = 2000 ELSE BONUS = 1000 END-IF
| Condition type | Example | Meaning |
|---|---|---|
| Relational | IF DEPT EQ 'ACC' | Field equals literal or other field |
| Series (THRU) | IF SERVICE EQ 6 THRU 10 | Value in inclusive range |
| Class | IF EMPL-NUM NUMERIC | Field content passes class test |
| Combined AND | IF STATUS EQ 'A' AND GROSS GT 0 | All parts must be true |
| Combined OR | IF REGION EQ 'E' OR REGION EQ 'W' | Any part true suffices |
Compare fields to literals or other fields with EQ equal, NE not equal, LT less than, GT greater than, LE less or equal, GE greater or equal. Spelling out EQ instead of equals sign is Easytrieve tradition—readable in column-oriented listings. Compare like types when possible: numeric to numeric, character to quoted literal. Mixing types may invoke conversion rules that surprise beginners—test boundary values in FLDCHK debug runs.
Broadcom documentation states AND-connected conditions evaluate before OR groups. Within an AND chain, all must be true for the chain to succeed. Within OR, any true condition makes the OR group true. Parentheses in some expression contexts clarify intent—when in doubt, split complex logic into nested IF blocks or named PROCs for auditability. Operations teams reviewing payroll exceptions prefer readable nested IF over single line with four AND connectors.
1234567IF EMPL-NUM NUMERIC AND EMPL-NUM GT 15555 PRINT EXCEPTION-RPT END-IF IF REGION EQ 'N' OR REGION EQ 'S' OR REGION EQ 'E' WS-ZONE = 'COASTAL' END-IF
DO WHILE condition repeats a block while condition stays true—boolean logic identical to IF expression grammar. Increment counters inside the loop and ensure condition eventually becomes false to avoid infinite batch jobs consuming CPU until operators cancel. Combine with GOTO and END-DO per program style guides at your site.
Single-character flags are the closest storage analog to boolean. ACTIVE A 1 holds Y or N. ERROR-FLAG A 1 holds space or E. PROCESS-IND N 1 0 holds 0 or 1. Assignment sets flag; IF tests flag. Multiple flags sometimes pack into one binary B field with bit masks—each bit acts as independent boolean at the hardware level. Choose character flags when humans read dumps; choose bits when interfacing binary APIs.
| Pattern | DEFINE example | True test |
|---|---|---|
| Y/N character | VALID-FLAG W 1 A | IF VALID-FLAG EQ 'Y' |
| Numeric 0/1 | DONE-IND W 1 N 0 | IF DONE-IND EQ 1 |
| Routine result | DATEVAL-FLAG W 3 A | IF DATEVAL-FLAG EQ 'YES' |
| Bit in binary | STATUS W 2 B | After AND mask, test bit field |
Class conditions test field content category without comparing to a specific value. NUMERIC asks whether characters are valid digits for numeric conversion. ALPHABETIC and related class tests appear in validation before arithmetic. Use class conditions as guards—IF ACCT NUMERIC AND ACCT GT 0 prevents S0C7 on alphabetic garbage in account fields.
IF SERVICE EQ 6 THRU 10 assigns vacation hours only when service years fall in band six through ten inclusive. THRU replaces multiple OR comparisons for contiguous numeric ranges. Boundaries are inclusive on both ends per training manual examples. Off-by-one errors happen when developers use LT and GT instead of THRU without aligning endpoints.
Negate conditions with NE not equal or by restructuring IF ELSE branches. Some extended condition forms support NOT connector in logical expressions per release documentation. When negation grows confusing, prefer positive IF with clear ELSE over double negatives that confuse maintainers during midnight incident response.
IF conditions are program-flow boolean. AND OR XOR on assignment with hex masks are bit-level boolean on bytes—different layer. IF STATUS-FLAG EQ Y is flow control. F1 = F2 AND X'FFFE' clears bit zero in a halfword. Both are boolean in computer science terms but serve different purposes. See bit fields and hex values pages for mask layer.
Boolean is asking yes-or-no questions. Is it raining? If yes, take an umbrella. Easytrieve does not have a special true-false coin in your pocket—it asks questions about boxes labeled with field names. Is the box labeled SERVICE bigger than ten? If yes, do the bonus steps. Y and N stickers on a one-letter box are the closest thing to a true-false coin you can store.
1. Easytrieve has a native BOOLEAN data type letter on DEFINE:
2. Combined conditions with AND are true when:
3. A one-byte flag field is often defined as:
4. IF SERVICE EQ 6 THRU 10 is a:
5. DATEVAL-FLAG set to YES means: