Handling Tables
4.2 Initializing Values of Table Elements
Example 4–14 Initializing Alphanumeric Items
01 A-RECORD-ALT.
03 FILLER PIC X(30) VALUE IS
"AAAAAAAAAABBBBBBBBBBCCCCCCCCCC".
03 FILLER PIC X(30) VALUE IS
"DDDDDDDDDDEEEEEEEEEEFFFFFFFFFF".
.
.
.
01 A-RECORD REDEFINES A-RECORD-ALT.
03 ITEM1 PIC X(10) OCCURS 26 TIMES.
Figure 4–12 Memory Map for Example 4–14
1
2
3
4
5
6
Level 03
Longword number
Byte number
Level 01
ZK−6049−GE
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
A−RECORD
ITEM 1
ITEM 1
ITEM 1
A A A A A A A A A A B B B B B B B B B B C C C C
. . .
. . .
. . .
. . .
. . .
Byte contents at
initialization time
When redefining or initializing table elements, allow space for any fill bytes that
may be added due to synchronization. You do not have to initialize fill bytes, but
you can do so. If you initialize fill bytes to an uncommon value, you can use them
as a debugging aid in situations where a Procedure Division statement refers to
the record level preceding the OCCURS clause, or to another record redefining
that level.
You can also initialize tables at run time. To initialize tables at run time, use the
INITIALIZE statement. This statement allows you to initialize all occurrences of
a table element to the same value. For more information about the INITIALIZE
statement, refer to the Compaq COBOL Reference Manual.
Sometimes the length and format of table items are such that they are best
initialized using Procedure Division statements such as a MOVE statement to
send a value to the table.
4.3 Accessing Table Elements
Once tables have been created using the OCCURS clause, the program must have
a method of accessing the individual elements of those tables. Subscripting and
indexing are the two methods Compaq COBOL provides for accessing individual
table elements. To refer to a particular element within a table, follow the name
of that element with a subscript or index enclosed in parentheses. The following
sections describe how to identify and access table elements using subscripts and
indexes.
4.3.1 Subscripting
A subscript can be an integer literal, an arithmetic expression, a data name, or
a subscripted data name that has an integer value. The integer value represents
the desired element of the table. An integer value of 3, for example, refers to the
third element of a table.
4–12 Handling Tables
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......