Procedures are Easytrieve's primary modularization unit—named blocks you call instead of copying the same twenty lines at every control break. A batch JOB might PERFORM CALC-TAX from detail logic and again from an exception path. A report defines BEFORE-LINE. PROC the product invokes before each printed line without explicit PERFORM from your code. Online SCREEN activities use BEFORE-SCREEN and AFTER-SCREEN hooks around terminal I/O. All share PROC and END-PROC syntax but differ in who calls them and where they may appear. Broadcom scopes procedures to the activity: JOB procedures are invisible to REPORT in the same program unless duplicated. Nesting PERFORM calls modularizes further but recursion is forbidden. This overview maps procedure categories for beginners, contrasts user PROCs with automatic hooks, explains PERFORM flow, previews nesting scope and parameters covered in later section pages, and ties procedures to arrays, file processing, and control flow tutorials you already studied. Use it as the roadmap before diving into PROC, END-PROC, nested procedures, calling conventions, scope, and parameters pages.
| Family | Invoked by | Examples |
|---|---|---|
| User PROC | PERFORM in same activity | CALC-TAX, VALIDATE-INPUT, OPEN-FILES |
| Report procedure | Report writer automatically | BEFORE-LINE, AFTER-BREAK, BEFORE-BREAK |
| Screen procedure | SCREEN activity automatically | INITIATION, BEFORE-SCREEN, AFTER-SCREEN, TERMINATION |
User PROCs behave like paragraphs or sections in other languages—explicit call, explicit return via END-PROC. Report and screen procedures are event hooks tied to product lifecycle. Mixing them confuses beginners who PERFORM BEFORE-LINE from JOB logic—that hook runs only when report engine prints a line.
12345678910111213CALC-TAX. PROC IF GROSS GT EXEMPT-AMT TAX = (GROSS - EXEMPT-AMT) * RATE ELSE TAX = 0 END-IF END-PROC JOB INPUT PAYFILE PERFORM CALC-TAX IF TAX GT 0 PERFORM WRITE-TAX-RECORD END-IF
Label ends with period before PROC keyword per Easytrieve conventions. Statements between PROC and END-PROC execute on each PERFORM. Control returns to statement after PERFORM unless EXIT or STOP inside PROC terminates broader flow.
PERFORM name transfers control once per invocation. Nested PERFORM stacks returns like subroutine calls. END-PROC is mandatory delimiter; omitting it merges procedures with catastrophic compile errors or runaway flow. GOTO inside PROC can branch within procedure or exit depending on target labels—prefer structured IF and PERFORM over GOTO for maintainability. STOP RUN inside PROC ends entire program—not just procedure.
JOB activity PROCs serve JOB INPUT and JOB logic. REPORT activity PROCs serve that report subactivity. SCREEN PROCs belong to named SCREEN block. SORT activity may define PROCs for sort processing hooks. Cannot PERFORM JOB PROC from REPORT PROC—duplicate shared code into a Library macro included in both activities if maintenance requires single source. Activity boundary is compile-time enforcement beginners hit when copying sample code across sections.
Broadcom requires report special procedures immediately after the REPORT subactivity they serve—not grouped at file bottom far from REPORT statement. BEFORE-LINE runs before detail line print; AFTER-LINE after. BEFORE-BREAK and AFTER-BREAK bracket control field changes. Sequence matters for readability and some release diagnostics. See report control breaks tutorial for WHEN BREAK interaction.
123456789REPORT PAYRPT SEQUENCE DEPT EMP-NO LINE DEPT EMP-NO GROSS TAX BEFORE-LINE. PROC IF LINE-COUNT GT 55 SKIP 2 END-IF END-PROC
INITIATION once at SCREEN start. BEFORE-SCREEN each display cycle before map send. AFTER-SCREEN after terminal input. TERMINATION at SCREEN end. Restrictions apply: GOTO SCREEN invalid in BEFORE-SCREEN. Screen procedures parallel report hooks but target online I/O. Batch programmers learning SCREEN should read screen section tutorial after this overview.
PROC A may PERFORM B; B may PERFORM C. Depth limited by product and shop standards—not infinite recursion. A calling B calling A is recursion and forbidden. Design leaf PROCs for smallest reusable units—format date, validate state code—and composite PROCs that PERFORM leaves. Array iteration tutorials use PERFORM PROCESS-ELEMENT inside DO loops—same modular idea.
Easytrieve also documents paragraph labels for GOTO targets without full PROC envelope in some contexts. Procedures are preferred for PERFORM modularization. Paragraphs suit sparse GOTO flow in legacy code. New development should default to PROC and END-PROC for clarity. Paragraphs page compares details.
MACRO in Library expands at compile time—copy source in multiple activities. PROC is runtime call in one activity. Share cross-activity logic with macros; share repeated logic within activity with PROC. Macro page covers WHEN to choose expansion versus call overhead—usually negligible in batch.
A procedure is a recipe card with a name. When the main program says perform recipe CALC-TAX, the computer follows that card and comes back to continue the main recipe. Some recipe cards are called automatically by the report printer before each line—that is BEFORE-LINE. You cannot use the report card from the homework section and the homework card from the report section—they live in different binders called activities.
1. User procedures are invoked with:
2. Procedures are local to:
3. Report BEFORE-LINE is:
4. Recursion between PROCs is:
5. Every PROC must end with: