SET Statement [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
SET Statement
The SET statement establishes reference points for table handling
operations by setting index names associated with table elements. This
statement can also be used to alter the status of external switches, and
to alter the value of conditional variables.
Syntax
The formats of the SET statement are shown below:
Parameters
identifier-1, must each name either index data items or
identifier-2 elementary items described as integers.
identifier-3 must be described as an elementary numeric integer.
integer-1 and may be signed, with the restriction that integer-1
integer-2 must be positive.
index-name-1, each related to a given table.
index-name-2, and so
forth
mnemonic-name-1 must be associated with a software switch, whose
status can be altered. This name is associated
with a software switch in the SPECIAL-NAMES
paragraph in the ENVIRONMENT DIVISION.
condition-name-1 must be associated with a conditional variable.
NOTE The value of the index associated with an index name may be
undefined following the execution of a SEARCH or PERFORM statement
in which it is used. Also, when a sending and a receiving item
share part of their storage areas, the result of execution of a SET
statement using them is undefined.
SET Statement - Format 1
If you use index-name-2, the value of the associated index before
execution of the SET statement must correspond to an occurrence number of
an element in the table whose index is being set.
Index-name-1, if used, is set to a value causing it to refer to the table
element whose occurrence number corresponds to the occurrence number of
the table element referenced by index-name-2, identifier-2, or integer-1.
The value to which index-name-1 is set must correspond to an occurrence
number of an element in the table to which index-name-1 is associated.
If identifier-2 is an index data item, or if index-name-2 is related to
the same table as index-name-1, no conversion takes place.
If identifier-1 is an index data item, it may be set equal to the
contents of either index-name-2 or identifier-2 if identifier-2 is an
index data item. No conversion takes place. Identifier-1 may not be set
equal to integer-1 in this case.
If identifier-1 is not an index data item, only index-name-2 may be used.
The value to which identifier-1 is set is, in this case, an occurrence
number that corresponds to the value of index-name-2.
Any indexing or subscripting associated with identifier-1 is evaluated
immediately before the value of the indexed or subscripted data item is
changed.
Any remaining identifiers or index names are set in the same way, with
the same restrictions as identifier-1 or index-name-1. If index-name-2
or identifier-2 has been specified, its associated value is used as it
was at the beginning of the execution of the SET statement.
Table 9-6 shows the validity of various operand combinations in the
SET statement.
Table 9-6. Validity of Different Combinations of Operands in the SET Statement
-------------------------------------------------------------------------------------------------
| | |
| | Receiving Item |
| Sending Item | |
| | |
-------------------------------------------------------------------------------------------------
| | | | |
| | Integer Data Item | Index Name | Index Data Item |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| Integer Literal | Not allowed | Valid | Not allowed |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| Integer Data Item | Not allowed | Valid | Not allowed |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| Index Name | Valid | Valid (1) | Valid (2) |
| | | | |
-------------------------------------------------------------------------------------------------
| | | | |
| Index Data Item | Not allowed | Valid (2) | Valid (2) |
| | | | |
-------------------------------------------------------------------------------------------------
(1) No conversion takes place if row sizes are equal.
(2) No conversion takes place.
SET Statement - Format 2
When format 2 is used, the value of the index associated with an index
name to be set must correspond, before and after execution of the SET
statement, to an occurrence number of an element in the associated table.
The value of index-name-3 is incremented (if UP BY is used) or
decremented (if DOWN BY is used) by the value of integer-2 or the integer
named by identifier-3.
If other index names are specified, each is set up or down, as specified,
just as the first was. The value of identifier-3 is unchanged and is
used as it was at the beginning of the execution of the SET statement.
SET Statement - Format 3
In format 3, the status of each external software switch associated with
mnemonic-name-1 is modified such that the truth value resultant from
evaluation of a condition name associated with that switch reflects an
"on status" if the ON phrase is specified, or an "off status" if the OFF
phrase is specified.
SET Statement - Format 4
In format 4, the literal in the VALUE clause associated with
condition-name-1 is placed in the conditional variable according to the
rules of the VALUE clause. If more than one literal is specified in the
VALUE clause, the conditional variable is set to the value of the first
literal that appears in the VALUE clause.
If multiple condition names are specified, the results are the same as if
a separate SET statement had been written for each condition-name-1 in
the same order as specified in the SET statement.
MPE/iX 5.0 Documentation