Easytrieve Operator Cheat Sheet

Operators are the punctuation of Easytrieve logic—comparing department codes, combining conditions, moving values between fields, and adding totals. This cheat sheet lists relational, logical, assignment, and arithmetic operators with plain-language meaning, typical IF examples, and pitfalls beginners hit when types or lengths do not match. Print it beside your terminal or bookmark it during code review. Each row links mentally to dedicated operator tutorials in this site for precedence, EOF tests, and migration notes. Broadcom Report Generator 11.6 follows classic Easytrieve expression rules; verify edge cases in your compile listing when upgrading.

Progress0 of 0 lessons

Relational Operators

Relational operators compare two values in IF, DO WHILE, and similar expressions. They return true or false for the condition. Numeric fields compare by numeric value; alphanumeric fields compare by character sequence (collating sequence on mainframe). Mixed-type compares follow Language Reference conversion rules—prefer explicit types in DEFINE and FILE to avoid surprises.

Relational operators
OperatorAlternateMeaningExample
EQ=EqualIF DEPT EQ 911
NE¬= / <>Not equalIF STATUS NE 0
GT>Greater thanIF GROSS GT 0
LT<Less thanIF COUNT LT 100
GE>=Greater or equalIF DATE GE WS-START
LE<=Less or equalIF QTY LE MAX-QTY

Logical Operators

Logical operators combine multiple conditions. AND requires all parts true. OR requires at least one part true. NOT inverts a condition. Complex filters use parentheses where your release supports grouping—document non-obvious logic in comments. Short-circuit behavior may differ by release; do not rely on side effects in unused branches.

Logical operators
OperatorMeaningExample
ANDAll conditions must be trueIF DEPT EQ 911 AND GROSS GT 0
ORAt least one condition trueIF REGION EQ 1 OR REGION EQ 2
NOTReverse conditionIF NOT EOF PAYROLL
text
1
2
3
4
5
6
7
IF DEPT EQ 911 AND GROSS GT 50000 PRINT HIGH-PAY-RPT END-IF IF REGION EQ 'E' OR REGION EQ 'W' PERFORM REGION-TOTAL END-IF

Assignment and MOVE

MOVE copies from source to target. Assignment statements may use = in some expression contexts per release. Watch length—moving long alphanumeric to shorter field truncates. Moving numeric to alphanumeric may require edit masks or conversion. Multiple targets can sometimes receive the same source in one statement depending on grammar. See assignment and MOVE tutorials for COBOL migration differences.

Assignment patterns
FormUse
MOVE TARGET SOURCECopy field or literal to TARGET
MOVE A B CMultiple targets from one source where allowed
TARGET = expressionAssign result of expression where supported
ADD A BAdd B into A (accumulator patterns)

Arithmetic Operators

Addition, subtraction, multiplication, and division appear in assignment expressions and ADD statements. Packed decimal fields preserve scale when defined with decimals. Division by zero causes runtime errors—guard with IF. Rounding follows packed rules; financial apps document half-up expectations in comments.

Arithmetic
OperatorMeaningNote
+AddADD statement or expression
-SubtractWatch packed sign
*MultiplyOverflow on small fields
/DivideTest divisor not zero

Special Comparisons

Special tests
TestMeaning
EOF fileEnd of file reached on named file after read
HIGH-VALUESCompare to maximum collating value constant
LOW-VALUESCompare to minimum collating value constant
SPACE / SPACESBlank alphanumeric test in conditions

Operator Precedence (Practical Rules)

  1. Parentheses group conditions when supported—use for clarity even if optional.
  2. NOT applies to nearest condition—use parentheses for NOT (A AND B) intent.
  3. AND often binds tighter than OR—verify complex expressions with compile listing tests.
  4. When in doubt, split into nested IF blocks—readability beats clever one-liners.

Common Operator Mistakes

  • Using = for comparison where grammar requires EQ word form in some contexts.
  • Comparing packed to alphanumeric without conversion.
  • IF DEPT EQ 911 versus EQ '911'—numeric versus character DEPT type.
  • Forgetting NOT EOF before GET in manual read loops.
  • MOVE truncating keys used later in SORT or match logic.

Per-Operator Tutorial Links

Deep dives: EQ, NE, GT, LT, GE, LE, AND, OR, NOT, MOVE, assignment under /operators/ in this tutorial. Use those pages for migration quirks and report writer interactions.

Explain It Like I'm Five

Operators are question words and actions. EQ asks are these the same? GT asks is this bigger? AND means both questions must be yes. MOVE means copy this sticker to that box. The cheat sheet is the small card on the desk so you do not forget the question words while doing homework.

Exercises

  1. Write IF with AND filtering department and minimum pay.
  2. Rewrite one IF using OR instead of two separate IFs—when equivalent?
  3. Write NOT EOF test before a GET loop pseudocode.
  4. Identify type mismatch risk in IF comparing N field to quoted literal.
  5. List relational operators and one payroll example for each.

Quiz

Test Your Knowledge

1. EQ and = in Easytrieve both mean:

  • Equal comparison in IF conditions
  • Assignment only
  • Sort ascending
  • File open

2. IF A GT 0 AND B LT 100 requires:

  • Both conditions true for nested statements to run
  • Only A true
  • Only B true
  • Neither

3. NE means:

  • Not equal
  • Negative number
  • New entry
  • No error

4. MOVE TARGET SOURCE:

  • Copies value from SOURCE to TARGET field
  • Opens file SOURCE
  • Sorts TARGET
  • Deletes SOURCE

5. NOT in logical expressions:

  • Reverses truth of following condition
  • Deletes a field
  • Ends IF block
  • Negates numeric sign only
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 expression operatorsSources: Broadcom Easytrieve 11.6 Language Reference expressions and operatorsApplies to: Easytrieve relational logical and assignment operators