COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-176
PERFORM VARYING
•
Restrictions for Identifiers
When the vary-1 or vary-2 operand is an identifier, and the associated
base-1 or base-2 is not an index-name, these restrictions apply:
°
The vary-1 or vary-2 identifier must designate a numeric data item. It
cannot designate a special register.
°
The associated base-1 or base-2 operand must be a numeric literal or an
identifier that designates a numeric data item.
°
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-55. 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)
...