COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-212
SEARCH VARYING
2. When a condition evaluates to TRUE, the search operation terminates
immediately. If that condition is followed by the NEXT SENTENCE phrase,
control passes to the next executable sentence; otherwise, the associated
imperative-stmt-2 is executed and control passes to the end of the
SEARCH statement (unless the imperative-stmt-2 explicitly transfers
control elsewhere using a GO TO statement).
3. When all conditions evaluate to FALSE, the index-name value is incremented
to correspond to the next occurrence number.
4. When the new value of the search index-name corresponds to an occurrence
number greater than the one that identifies the last element of the table, the at-
end condition exists and the search operation terminates immediately;
otherwise, the search operation repeats from Step 1.
When the search operation terminates due to the at-end condition, imperative-
stmt-1 is executed, if the AT END phrase is specified. Control then passes to the
end of the SEARCH statement (unless imperative-stmt-1 explicitly transfers
control elsewhere using a GO TO statement).
•
Multidimensional Tables
If table is an element of another table, you have a multidimensional table. Each
dimension of the multidimensional table must be declared with an INDEXED
phrase. A SEARCH statement uses only the first index of each dimension. To
search an entire multidimensional table, you must execute several SEARCH
statements. Before each execution of a SEARCH statement, you must execute a
SET statement to adjust index-names to appropriate settings. The index-names
must be used in the SEARCH statement’s condition.