table.FETCH_LOC_NEXT Function
Syntax
Arguments
- pattern
An expression that specifies the field value to find. Not case sensitive.
- fieldname
Optional. Default = all fields. The name of the single field to search in.
Description
Locate the next value/pattern if the field specified.
Discussion
The <TBL>.FETCH_LOC_NEXT() method fetches the next record in the table referenced with a field value that contains Matching_Expression. The search starts with the current record (or the next record if the current record was found by a <TBL>.FETCH_LOC_NEXT()and continues until it reaches the last record in the active range, index, or query list. When you supply the optional Fieldname parameter, <TBL>.FETCH_LOC_NEXT()searches only this field. If a Fieldname is not specified, all the fields in the table are searched. When <TBL>.FETCH_LOC_NEXT()finds a record with a matching field, it returns TRUE (.T.). This record becomes the current record. If no exact match is found, the result is FALSE (.F.). If <TBL>.FETCH_LOC_NEXT()does not find a match, the record pointer is not moved. <TBL>.FETCH_LOC_NEXT()searches for any occurrence of the Matching_Expression. For example, if the Matching_Expression evaluates to "software", and a particular record contains "Alpha Software Corporation", a match is found. Searches performed using the <TBL>.FETCH_LOC_NEXT() method can be slow in large tables because each record must be fetched and scanned. Lightning Query Optimization cannot be used to optimize the search. If the field you want to search is indexed, and the value you want to find is at the start of the field, you should consider using the <TBL>.FETCH_FIND() method.
Example
This script counts the number of times a value occurs anywhere in the current table.
dim tbl as P value = ui_get_text("Counter", "Value to count:") if value = "" then end end if tbl = table.current() 'Reading records in record number order is fastest, so set order record order tbl.index_primary_put() tbl.fetch_first() count = 0 while tbl.fetch_loc_next(value) count = count + 1 end while trace.writeln(value + " found " + LTRIM(STR(count)) + " times.")
See Also