Skip to content

FIND

Read Data if Present

This directive is used to test for a specific data record in a file and, if found, READ data from the data record in the file. If not found, this directive does not update the record pointer for the file as a READ does.

FIND (channel [,I/O-opts]) [variable-list] [,IOL=line-ref]
FIND RECORD (channel [,I/O-opts]) string-variable
channel
is an integer in the range of 0 to 32764 indicating the channel of an OPEN file.
I/O-opts
is one or more of the following specifiers:
Record
IND=numeric-value KEY=string-value SRT=sort-name
Branching
ERR=line-ref DOM=line-ref END=line-ref
Miscellaneous
TBL=line-ref ERC=error-code
variable-list
is a list of numeric and/or string variables that receive values from the record.
line-ref
is a program line number or label containing an IOLIST that defines a variable list (the IOL= option may be used by itself or together with a variable list; the comma preceding IOL= is used only when a variable precedes IOL=), or the program line number or label to branch to if the specified error occurs.
string-variable
is the name of a string variable that receives the entire record as data.

This directive should not be used to input data from a terminal.

Refer to the READ directive for all options and additional notes.

This directive acts like the READ directive, with one exception: if a READ is issued to a key that does not exist, an ERR=11 results, and the value of the KEY function returns the next valid key value after the key that was specified in the unsuccessful READ. FIND also returns an ERR=11 but does not change the position of its key pointer. The value of the KEY function returns the next sequential valid key value to the last successful FIND or READ. In other words, a missing key error for a READ moves its key pointer while a missing key error for a FIND does not move its key pointer.

A FIND on a SORT file does not transfer data since there is no data to transfer; the record pointer is updated if the FIND is successful.

FIND (1) A$, A

accesses the current record in the file OPEN on channel 1 and transfers data from the first field to the variable A$ and from the second field to the variable A. The record pointer is updated to the next sequential record if the FIND is successful; otherwise an error is produced and the record pointer remains at the value of the previous record.

FIND RECORD (1) B$

accesses the current record in the file OPEN on channel 1 and transfers the entire record, including delimiting characters, into the variable B$.

FIND RECORD (1,IND=X, ERR=7999)B$

If X=56; this acts like the previous example, but it accesses the record having the index number 56 and branches to statement 7999 if the directive produces an error condition.

FIND (1, KEY=I$) IOL=5000

If I$=“ASD#123” and statement 5000 is IOLIST A$,A, this has the same effect as the first example, but accesses the record with the key value “ASD#123”.

FIND (1, TBL=459) *, A

has the same effect as the first example, but skips the first field and enters data from the second field into the variable A; accesses statement 459 for the TABLE statement to use for code conversion of the data.

READ directive

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF