COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-223
SET TO
Usage Considerations:
•
Index-Names and Index Data Items
An index-name is directly associated with a table and is declared in the INDEXED
phrase of the table’s data description entry. The value associated with an index-
name is related only to the table with which it is defined.
An index data item is a separate data item, not associated with any table, that is
declared with the USAGE INDEX clause.
•
Copying and Converting Values
The SET statement performs copying between indexes and index data items. It
also performs conversions from indexes to integer data items (occurrence
numbers) or from integer data items (occurrence numbers) to indexes. This
conversion is necessary because the values associated with indexes and index
data items are machine-architecture related, whereas the occurrence numbers are
not.
Table 9-10 summarizes these rules:
°
The receiving item (index-name-n ) is set to a value causing it to refer to the
table element corresponding in occurrence number to the table element
specified by the sending item (identifier-1, index-name-1, or integer
). If the sending item is an index data item, or if it is an index-name that is
related to the same table as the receiving item, no conversion occurs.
°
If the receiving item is an index data item, it can be set equal to the contents of
either an index-name or another index data item. No conversion occurs.
°
If the receiving item is not an index data item, it can be set only to an
occurrence number corresponding to the value of an index-name. The sending
item cannot be a numeric integer literal or a numeric integer data item.
°
The assignment process is repeated for any other receiving data-names
specified. Each time, the value of a sending data item is used as it was at the
beginning of the execution of the statement. Any subscripting or indexing
associated with the sending data item is evaluated immediately before the
value of the receiving data item is changed.
Table 9-10. Valid SET TO Combinations
Sending Item
Receiving Item
Integer Data Item Index-Name Index Data Name
Integer literal No (rule 3) OK (rule 1) No (rule 2)
Integer data item No (rule 3) OK (rule 1) No (rule 2)
Index-name OK (rule 3) OK (rule 1) OK (rule 2)
*
Index data item No (rule 3) OK (rule 1) OK (rule 2)*
* No conversion occurs