Command Reference 5-19
BSEARCH
Purpose Performs a binary search on a sorted lookup table to find a record containing a
specific value.
Syntax BSEARCH
lookup-field
,
value
[ , [
invalid label
] [ ,
valid label
] ]
Process The BSEARCH
command searches
lookup-field
for
value
. The script determines
which lookup table to use by the field you specify (every field name must be unique
over all lookup tables).
Optional Fields If the search is successful, the pointer points to the record and control passes to
valid label
(if defined). If the search is unsuccessful, the pointer is undefined and
control passes to
invalid label
(if defined). Otherwise, control passes to the next
line.
NOTE: You must sort the lookup table before downloading it to the printer.
Lookup-field
is the search field's logical name in the lookup table.
Value
is the value you are searching the field for and can be one of the following:
Value
Description
INPUT Input Buffer
Logical Field Name
(TEMP1)
Temporary Buffer
Field
Logical Field Name (LU1) Lookup Buffer Field
Logical Field Name (PR1) Printer Buffer Field
Logical Field Name
(Field1) [Index]
Array Buffer Field
Number
String
A number prefixed by
the number sign (#)
A one-character
ASCII string delimited
by double quotes
Lookup-field
and
value
must have the same data type.
Optional Fields
Invalid
and
valid labels
are discussed in “Script Flow" at the beginning this chapter.
Example
This example searches CONTROL_ID for the input buffer's contents. If no match is
found, control transfers to the *ERROR_ID label.
BSEARCH CONTROL_ID, INPUT, *ERROR_ID