COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-216
SEARCH ALL
arithmetic expression-2
is any arithmetic expression.
condition-name-1
is a condition (a level-88 item) that terminates the search operation.
condition-name-1 must be defined as having a single value. The data-
name with which condition-name-1 is associated must be specified as the
first in the KEY phrase of the OCCURS clause of table.
imperative-stmt-2
is an imperative statement to be executed when the condition that condition-
name-1 specifies 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.
Usage Considerations:
•
CONTINUE is Recommended Over NEXT SENTENCE
NEXT SENTENCE transfers control to the next period (.), while CONTINUE
transfers control to END-SEARCH. Either imperative-stmt-1, imperative-
stmt-2, or both can be CONTINUE statements.
•
Binary Search
HP COBOL performs a binary search when these conditions are met:
°
Each condition-name referenced in the WHEN clause must be defined as
having a single value.
°
The data-name associated with a condition-name must appear in the KEY
phrase in the OCCURS clause of the data definition of table.
°
Each identifier-1 must be subscripted by the first index-name associated
with table, along with other subscripts as required, and must be referenced in
the KEY phrase in the OCCURS clause of the data definition of table.
°
The identifiers mentioned in the operands must not be referenced in the KEY
phrase in the OCCURS clause associated with table, and must not be
subscripted by the first index-name associated with table.