Previous Topic: OPTION CommandNext Topic: PRINT Command


PERFORM Command

The PERFORM command causes a branch to a subroutine within the Reporting Facility program. The optional logic and expression specifies the condition under which the branch is to occur. At the end of the subroutine, control will pass to the next command following the PERFORM.

The PROC and ENDPROC commands define the limits of the subroutine to be executed by the PERFORM command.

The format of the PERFORM command is as follows:

►►─┬───────────┬─ PERFORM ─ label2 ─┬──────────────────────┬──────────────────►◄
   └─ label1: ─┘                    └─ logical expression ─┘
label1:

Specifies an optional identifying label, possibly referenced within a GOTO command, that allows branching to be made to this statement.

label2

Specifies the label attached to the statement to which control is to be passed. This label must be on a PROC command.

logical expression

Specifies the constraints under which any branching is to take place. If omitted, Reporting Facility performs the routine specified by the label unconditionally. When coded, the logical expression must be satisfied before any branching takes place. If the expression is not satisfied, control continues with the next command. Logical expressions cannot be ANDed together with PERFORM.

You can apply only branch labels to the following commands:

ADD
PROC,
COMPUTE,
CONTINUE

DECODE
DECREMENT
DIVIDE
ENDPROC

GET
GOTO
INCREMENT
MOVE

MULTIPLY
PERFORM
SET
SUBTRACT

Example

 GET DATA                                   define files and variables
 LABEL1: CONT
 SET A = B                                  other logic
 PERFORM SUB
 NOTE an implied GOTO TEST is generated here by RPT Facility
 SUB: PROC
 COMPUTE C = A * B
 SET B = C
 ENDPROC
 report section