COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-177
READ
In Example 9-56, each of the two paragraphs builds a table of numbers (rows) raised
to powers (columns). Each paragraph fills the 5 columns of row 1, then of row 2, and
so on.
READ
READ copies one logical record from a file and stores it in a record area defined by
your program.
Example 9-56. PERFORM VARYING Statement Used to Build a Table
WORKING-STORAGE SECTION.
01 TWO-D-TABLE.
03 OCCURS 10 TIMES.
05 PWR PICTURE 9(6) OCCURS 5 TIMES.
PROCEDURE DIVISION.
TWO-NESTED-PERFORMS.
PERFORM VARYING R FROM 1 BY 1 UNTIL R > 10
PERFORM VARYING C FROM 1 BY 1 UNTIL C > 5
COMPUTE PWR (R, C) = R ** C
END-PERFORM
END-PERFORM.
SINGLE-PERFORM-WITH-AFTER.
PERFORM VARYING R FROM 1 BY 1 UNTIL R > 10
AFTER C FROM 1 BY 1 UNTIL C > 5
COMPUTE PWR (R, C) = R ** C
END-PERFORM.
Form Reads the record that is ...
READ for Sequential or Dynamic Access
Next in the file
READ for Line Sequential Files
Next in the file
READ for Random or Dynamic Access
Identified by the value of a key