COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-218
SEARCH ALL
The SEARCH ALL operation proceeds in a binary fashion, successively setting the
index-name to correspond to different table elements and evaluating the target
condition. For each operand of the target condition, the process of operand
identification occurs just before its use each time the operand participates in the
determination of the value of the target condition.
•
When Exactly One Matching Element Is Found
When the target condition evaluates to TRUE, the search all operation terminates
and the value of the index-name corresponds to the element under consideration.
If the NEXT SENTENCE phrase is specified, control passes to the next executable
sentence; otherwise, imperative-stmt-2 is executed and then control passes
to the end of the SEARCH ALL statement (unless execution of imperative-
stmt-2 explicitly transfers control elsewhere using a GO TO statement).
If more than one element satisfies the condition, the index can point to any one of
them.
•
When No Matching Element Is Found
When the value of the target condition is FALSE, the search operation terminates
with the at-end condition and the value of the index-name is undefined. If the AT
END phrase is specified, imperative-stmt-1 is executed. Control passes to
the end of the SEARCH statement (unless execution of imperative-stmt-2
explicitly transfers control elsewhere using a GO TO statement).
•
Tables Defined With a DEPENDING Phrase
For a variable-occurrence table, only those elements currently defined as a part of
the table can be candidates. The last of these is the one specified by the maximum
occurrence number, which is the value of the associated DEPENDING data item.
•
Index Values
During the search operation, the first index-name appearing in the INDEXED
phrase of the OCCURS clause describing the table is varied so that its value
always corresponds to an occurrence number defined for the table. The value of
this index-name at the start of execution of the SEARCH statement is immaterial.