One of the first things beginners look for in Easytrieve is a general-purpose END statement, the way some languages use a single END to close any block. Easytrieve does not work that way, and it is important to say so plainly: there is no standalone END keyword in the language. Instead, Easytrieve provides a small family of hyphenated scope terminators, each named after the exact block it closes - END-IF for a conditional, END-DO for a loop, END-PROC for a procedure, and END-CASE for a CASE structure. This design is deliberate. Because each terminator names its block, the source reads clearly even when blocks are deeply nested, and the compiler can immediately flag a loop that was opened but never closed or an IF whose END-IF went missing. This page gathers the END family in one place so you can see how they relate, learn the one-to-one pairing rule that governs all of them, and understand the equally important fact that activities (JOB and SORT) are not closed by any terminator at all - they end when the next activity starts or when STOP runs. If you arrived here searching for "Easytrieve END statement", this is the page that explains what actually exists, why, and how to use each terminator correctly. We cover the format of every terminator, a comparison table, worked examples that show correct pairing, the STOP alternative for ending activities and the whole run, and the pairing mistakes that cause the most compile errors for newcomers.
Every block-opening statement in Easytrieve has a matching terminator, and you must use the one that belongs to that block. Writing a lone END will not compile. The table below lists each terminator, the statement it pairs with, and what happens when control reaches it. Learning these pairs is the whole skill: once you know which terminator closes which block, structured Easytrieve code becomes straightforward.
| Terminator | Closes the block opened by | Effect when reached |
|---|---|---|
| END-IF | IF (with optional ELSE-IF / ELSE) | Ends the decision; execution continues below |
| END-DO | DO WHILE / DO UNTIL | Marks the loop bottom; branches back to the test |
| END-PROC | PROC (procedure) | Returns control to the statement after PERFORM |
| END-CASE | CASE | Ends the multi-way selection block |
Note there is no END-JOB or END-SORT: activities are bounded differently, as explained further down. And ELSE-IF and ELSE never take their own terminator - the single END-IF closes the entire IF structure no matter how many branches it has.
END-IF terminates the logic associated with the previous IF statement. Exactly one END-IF is required per IF, and it closes any ELSE-IF and ELSE branches too. After END-IF, processing continues regardless of which branch ran.
12345678IF PAY-GROSS NOT NUMERIC DISPLAY EMP# ' PERSONNEL RECORD IS DAMAGED' GOTO JOB ELSE-IF PAY-GROSS > 500.00 XMAS-BONUS = PAY-GROSS * 1.03 ELSE XMAS-BONUS = PAY-GROSS * 1.05 END-IF
The one END-IF at the bottom closes the IF, the ELSE-IF, and the ELSE all at once. This is why multi-band decisions in Easytrieve stay tidy - there is never a stack of terminators to match.
END-DO terminates the body of the loop associated with a DO WHILE or DO UNTIL statement. When control reaches END-DO it branches back to re-evaluate the loop condition. An END-DO must be specified after each DO statement and its associated statements; nested loops each need their own.
123456DO WHILE COUNT-1 LT 10 COUNT-1 = COUNT-1 + 1 DO WHILE COUNT-2 < 10 COUNT-2 = COUNT-2 + 1 END-DO END-DO
The inner END-DO closes the inner loop and the outer END-DO closes the outer loop. Matching them by indentation is the easiest way to be sure each loop is closed at the right point.
END-PROC delimits the statements in a procedure defined by a PROC statement. A procedure is a named group of statements you invoke with PERFORM. When execution reaches END-PROC, control returns to the statement following the PERFORM that called it.
1234FINISH-PROC. PROC DISPLAY 'TOTAL $ SPENT IN BONUS ' + 'MONEY ====> ' TOT-XMAS-BONUS END-PROC
Every PROC must have an END-PROC. The procedure name and the PROC keyword open the block; END-PROC closes it and sends control back to the caller.
A CASE structure chooses one path from many based on the value of a field. END-CASE marks the end of that multi-way selection, in the same way END-IF ends a two-way decision. If you use CASE, you close it with END-CASE, not with END-IF.
12345678CASE REGION-CODE CASE 'N' PERFORM PROCESS-NORTH CASE 'S' PERFORM PROCESS-SOUTH OTHERWISE PERFORM PROCESS-OTHER END-CASE
Activities are the exception. A JOB or SORT activity has no closing keyword. It ends automatically when the next JOB or SORT activity begins, or when a STOP statement runs. This surprises people who expect an END-JOB. STOP ends the current activity, still running any FINISH procedure attached to it, and then moves on to the next activity if one exists. STOP EXECUTE is stronger: it ends all activities immediately without continuing to the next one.
| What you want to end | What you code |
|---|---|
| An IF decision | END-IF |
| A DO loop | END-DO |
| A procedure | END-PROC |
| A CASE selection | END-CASE |
| The current JOB/SORT activity | STOP (or start the next activity) |
| The entire program immediately | STOP EXECUTE |
Think of each kind of block as a different box with its own lid. A loop box has a lid called END-DO. A yes/no box has a lid called END-IF. A helper-task box has a lid called END-PROC. You have to put the right lid on the right box - you cannot use one magic lid for everything, and there is no plain lid just called END. And the big work sessions (the activities) do not get a lid at all; they finish when the next session starts or when someone says STOP.
1. Is there a standalone END statement in Easytrieve?
2. Which terminator closes a DO WHILE or DO UNTIL loop?
3. Which terminator marks the end of a procedure?
4. How do you end a JOB or SORT activity - is there an END-JOB?
5. What is the effect of a missing END-IF?