BBjRecordSet::seek

Description

In BBj 4.0 and higher, this method seeks forward from the beginning of the BBjRecordSet for a particular BBjRecordData object.

Syntax

Return Value

Method

void

seek(BBjRecordData recordData)

void

seek(BBjRecordData recordData, boolean partial)

Parameters

Variable

Description

recordData

Specifies a BBjRecordData object.

partial

0 – require full match of each non-blank field

1 – allow partial match of each non-blank field

Return Value

None.

Remarks

Starting from the beginning of the recordset, this method scans forward record by record, moving toward the end of the recordset. For each record retrieved from the recordset, it compares each non-blank field from the specified record. If a matching record is found, it becomes the new current record. If no matching record is found, an error is generated and the current record is unchanged. To initialize the record for scanning, always start with an empty record (see BBjRecordSet::getEmptyRecordData), then set only those fields that are necessary to uniquely identify the record. Note that this method scans sequentially through the file, and could be slow with large recordsets.

If the partial parameter is not supplied, seek will require a full match.

Example

rem ' Seek forward in a BBjRecordSet for a particular BBjRecordData

rem ' First, create a data file
FILENAME$="BBjRecordSet.dat"
MODES$=""
TEMPLATE$="STATE:C(2),NAME:C(16* = )"
erase FILENAME$,err=*next
mkeyed FILENAME$,[0:1:2],0,32
channel = unt
open (channel)FILENAME$
dim REC$:TEMPLATE$

rem ' Load the file with state codes and names
while 1
    dread rec.state$,rec.name$,END=*break
    write record (channel)rec$
wend
close (channel)

rem ' Create a file-based BBjRecordSet
RecordSet! = BBJAPI().createFileRecordSet(FILENAME$,MODES$,TEMPLATE$)
for x = 1 to 15
    RecordSet!.next()
next x

rem ' Find the record for Guam
RecordSet!.first()
while(1)
    RecordData! = RecordSet!.getEmptyRecordData()
    RecordData!.setFieldValue("state","G")
    RecordSet!.seekForward(RecordData!,1,err = NOKEY)

    rem ' Retrieve the RecordData for the current record (Guam)
    RecordData! = RecordSet!.getCurrentRecordData()

    rem ' Print the RecordData
    print "A G Partial match:",'LF',RecordData!,
    continue
    NOKEY: print "END OF G RECORDs"; break
wend
stop
DATA "AK","Alaska"
DATA "AL","Alabama"
DATA "AR","Arkansas"
DATA "AZ","Arizona"
DATA "CA","California"
DATA "CO","Colorado"
DATA "CT","Connecticut"
DATA "DC","District of Columbia"
DATA "DE","Delaware"
DATA "FL","Florida"
DATA "GA","Georgia"
DATA "GU","Guam"
DATA "HI","Hawaii"
DATA "IA","Iowa"
DATA "ID","Idaho"
DATA "IL","Illinois"
DATA "IN","Indiana"
DATA "KS","Kansas"
DATA "KY","Kentucky"
DATA "LA","Louisiana"
DATA "MA","Massachusetts"
DATA "MD","Maryland"
DATA "ME","Maine"
DATA "MI","Michigan"
DATA "MN","Minnesota"
DATA "MO","Missouri"
DATA "MS","Mississippi"
DATA "MT","Montana"
DATA "NC","North Carolina"
DATA "ND","North Dakota"
DATA "NE","Nebraska"
DATA "NH","New Hampshire"
DATA "NJ","New Jersey"
DATA "NM","New Mexico"
DATA "NV","Nevada"
DATA "NY","New York"
DATA "OH","Ohio"
DATA "OK","Oklahoma"
DATA "OR","Oregon"
DATA "PA","Pennsylvania"
DATA "PR","Puerto Rico"
DATA "RI","Rhode Island"
DATA "SC","South Carolina"
DATA "SD","South Dakota"
DATA "TN","Tennessee"
DATA "TX","Texas"
DATA "UT","Utah"
DATA "VA","Virginia"
DATA "VI","Virgin Islands"
DATA "VT","Vermont"
DATA "WA","Washington"
DATA "WI","Wisconsin"
DATA "WV","West Virginia"
DATA "WY","Wyoming"

See Also

BBjAPI

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.