COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-210
SEARCH VARYING
table
is the name of a data item described with an “OCCURS … INDEXED BY index-1
… KEY …” clause. The search is done with index-1, which the search operation
initializes to the middle of the table before beginning to scan. Only the name of
table can appear, qualified if necessary, but not subscripted or reference
modified.
indexer
is one of:
°
One of the index-names in the INDEXED phrase in the definition of table
°
An integer data item (which can, itself, be subscripted)
°
An index data item
indexer cannot specify a special register. indexer cannot be subscripted by
the first (or the only) index-name specified in the INDEXED phrase of the
OCCURS clause of the definition of table.
When indexer is from the INDEXED phrase, that index is used to start the
search. When it is a separate item, index-1 from the INDEXED option is used to
search table, and indexer is incremented by 1 when index-1 is
incremented.
The SEARCH statement does not initialize its index (either indexer or
index-1 ). The value of the index at the time the search begins is used.
imperative-stmt-1
is an imperative statement to be executed when an at-end condition is detected
during the search.
condition
specifies a conditional expression used to control the search for an element.
imperative-stmt-2
is an imperative statement to be executed when a condition is satisfied.
NEXT SENTENCE
specifies that control be passed directly to the end of the SEARCH statement.
It is not recommended (see Usage Considerations:).
END-SEARCH
ends the scope of the SEARCH statement, causing the SEARCH to be a delimited-
scope statement. Without the END-SEARCH phrase, the SEARCH statement is a
conditional statement, which ends at the next period separator.