161
FIND_RECORD
Purpose
To search for records in a specified DBF file that matches the key string with
respect to a specified IDX.
Syntax A% = FIND_RECORD(file%, index%, key$)
Remarks “A%” is an integer variable to be assigned to the result.
“file%
” is an integer variable in the range of 1 to 5, indicating which DBF file to
be accessed.
“index%” is an integer variable in the rang
e of 1 to 3, indicating which IDX file
to be accessed.
“key$
” is a string variable, representing the character string which indicates the
matching string to be found.
If any record member in the DBF file matches the key string with respect to
the IDX file,
FIND_RECORD will return 1, and the file pointer of the IDX file
will point to the first record with the matching string.
If there is no match, the file pointer will point to the first record whose
index value is greater than the vale of “key$”.
Example
ON COM(1) GOSUB HostCommand
…
HostCommand:
Cmd$ = READ_COM$(1)
CmdIdentifier$ = LEFT$(Cmd$, 1)
DBFNum% = VAL(MID$(Cmd$, 2, 1))
IDXNum% = VAL(MID$(Cmd$, 3, 1))
CardID$ = RIGHT$(Cmd$, LEN(Cmd$)-3)
IF CmdIdentifier$ = “?” THEN
IF FIND_RECORD(DBFNum%, IDXNum%, CardID$) = 1 THEN
PRINT “Data is found in DBF.”, DBFNum%
ELSE
PRINT “Data is not found in DBF.”, DBFNum%
END IF
ELSE