COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division Verbs
HP COBOL Manual for TNS/E Programs—520347-003
9-164
PERFORM VARYING
°
The associated step-1 or step-2 must be a numeric literal or an identifier
that designates a numeric data item.
•
Execution Cycles of PERFORM Statements (PERFORM Cycles)
Execution of a PERFORM statement causes none, one, or more executions of its
range. These executions are called PERFORM cycles. The number of PERFORM
cycles depends upon the values of the operands of the PERFORM statement. The
decision of whether to perform the first cycle or not occurs after any initialization
specified in the VARYING and FROM phrases.
•
See Usage Considerations: in Unconditional PERFORM.
Example 9-53. PERFORM VARYING Statement Used to Display a List
WORKING-STORAGE SECTION.
01 COMMAND-DATA.
05 FILLER PIC X(36)
VALUE "ADD - ADD A NEW RECORD".
05 FILLER PIC X(36)
VALUE "DELETE - DELETE A RECORD".
...
01 COMMAND-TABLE REDEFINES COMMAND-DATA.
05 COMMAND-ENTRY PIC X(36) OCCURS 10 TIMES.
01 COMMAND-NUMBERS.
05 NO-OF-COMMANDS PIC 99 VALUE 9.
05 COMMAND-SUB PIC 99 COMP VALUE 1.
PROCEDURE DIVISION.
...
PERFORM LIST-COMMANDS
VARYING COMMAND-SUB FROM 1 BY 1
UNTIL COMMAND-SUB GREATER THAN NO-OF-COMMANDS
...
LIST-COMMANDS.
DISPLAY COMMAND-ENTRY(COMMAND-SUB)
...










