A condition is the test inside IF and inside DO WHILE. It can compare two values, ask whether a field is numeric, ask whether a file is finished, or combine those tests with AND and OR. The same test is legal in both places. ELSE and END-IF belong to the IF statement. They are not part of the condition itself.
| Kind | Example |
|---|---|
| Relational | IF STATUS EQ 'A' |
| Series | IF DIVISION = 'A', 'B', 'C' |
| Class | IF AMOUNT NUMERIC |
| End of file | IF EOF RATES |
| Matched files | IF MATCHED file-1, file-2 |
| Duplicate | IF DUPLICATE file-name |
EQ, NE, GT, GE, LT, and LE compare a field to a field or a literal. A series lists several literals after one operator. Parentheses group a mix of AND and OR so the rows you PRINT are the rows you described.
123456789IF STATUS EQ 'A' AND GROSS GT 0 PRINT PAY-RPT ELSE PUT EXCEPTION END-IF IF DIVISION = 'A', 'B', 'C' DEDUCTIONS = GROSS * 0.15 END-IF
DO WHILE checks the condition before the body. DO UNTIL checks after. END-DO closes either one. A WHILE that never changes the field you test does not finish. Count, or GET a file and stop on EOF.
12345GET RATES DO WHILE NOT EOF RATES * use the rate row GET RATES END-DO
IF is a question you ask each card. EQ is "does it say A?" AND is "and is the number bigger than zero?" EOF is "is the box empty?" DO WHILE keeps asking the same question until the answer changes.
1. The same condition can appear on:
2. IF STATUS EQ 'A' is a:
3. IF field = 'A', 'B', 'C' tests:
4. IF EOF MASTER after GET means:
5. AND and OR in one IF need: