Specifications

Chapter 15. Function Reference
378
Syntax:
SEARCH([#]filenumber,fieldvariable,searchdata
[,startrecord])
Parameter:
filenumber
A numeric expression which returns a value from 1 to 16.
fieldvariable
A non-array string variable.
searchdata
A string expression.
startrecord
A numeric expression which returns a value from 1 to 32767.
Description:
SEARCH searches a target field specified by fieldvariable in a data file spec-
ified by filenumber for data specified by searchdata, starting from a record
specified by
startrecord, and then returns the record number where the search
data is found.
fieldvariable is a string variable defined by a FIELD statement.
searchdata is the data you are looking for.
startrecord is a record number where the search is to begin in a data file.
The search ends when all of the written records have been searched.
If you omit
startrecord option, the search begins at the first record (record
#1) of the data file.
If the search data is not found,
SEARCH returns the value 0.
A convenient use for SEARCH is, for example, to search for a particular product
name, unit price, or stock quantity in a product master file by specifying a bar
code data to
searchdata.
Since the search begins at a record specified by startrecord in a data file
and finishes at the last record, sorting records in the data file in the order of fre-
quency of use before execution of this function will increase the searching speed.
SEARCH File I/O function
SEARCH
Searches a specified data file for specified data, and then returns the record
number where the search data is found.