Difference between revisions of "LOCATE"
Yvonnemilne (Talk | contribs) |
Helengeorge (Talk | contribs) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Search the active table for records that satisfy a certain condition | Search the active table for records that satisfy a certain condition | ||
Line 19: | Line 12: | ||
==See Also== | ==See Also== | ||
− | CONTINUE, FIND, INDEX, SCAN, SEEK, SET FILTER, SET RELATION | + | [[CONTINUE]], [[EOF()]], [[FIND]], [[INDEX]], [[SCAN]], [[SEEK]], [[SET FILTER]], [[SET RELATION]] |
Line 34: | Line 27: | ||
The search starts from the current record and searches he rest of the records in the table for a record matching the specified condition. FOUND() will return .F. and EOF() will return .T. if no record matching the condition is located. | The search starts from the current record and searches he rest of the records in the table for a record matching the specified condition. FOUND() will return .F. and EOF() will return .T. if no record matching the condition is located. | ||
− | The CONTINUE command works in conjunction with LOCATE, in order to continue the search through the table. The | + | The CONTINUE command works in conjunction with LOCATE, in order to continue the search through the table. The SCAN...ENDSCAN command performs a similar function, but is more efficient. |
Line 42: | Line 35: | ||
locate for event = "DREAM" | locate for event = "DREAM" | ||
do while found() | do while found() | ||
− | + | display event, name, seats, seats * price | |
− | + | continue | |
enddo | enddo | ||
</code> | </code> | ||
Line 49: | Line 42: | ||
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
+ | [[Category:Table Basics]] | ||
+ | [[Category:Table Basics Commands]] |
Latest revision as of 17:16, 11 November 2009
Contents
Purpose
Search the active table for records that satisfy a certain condition
Syntax
LOCATE [<scope>]
[FOR <condition>]
[WHILE <condition>]
See Also
CONTINUE, EOF(), FIND, INDEX, SCAN, SEEK, SET FILTER, SET RELATION
Description
The LOCATE command evaluates the specified FOR <condition> against each of the records in the active table, within the specified <scope>. If a record is successfully located, the Recital/4GL FOUND() function will return .T., and the EOF() function will return .F.. If your table is large, you are advised to INDEX it and use the SEEK command followed by the LOCATE REST command. This method is much more efficient. If SET FILTER TO <condition> is in effect, only those records that satisfy the <condition> are processed. If no FOR clause is specified, then all records that are not filtered are located.
<scope>
If no <scope> is specified, the default ALL is used, unless the WHILE clause is specified in which case the default <scope> will be REST.
FOR <condition>
If no record is found to satisfy the FOR <condition>, the FOUND() function will return .F.. If the <end of scope> is encountered before the <end of file>, then the EOF() function will still return .F..
WHILE <condition>
The search starts from the current record and searches he rest of the records in the table for a record matching the specified condition. FOUND() will return .F. and EOF() will return .T. if no record matching the condition is located.
The CONTINUE command works in conjunction with LOCATE, in order to continue the search through the table. The SCAN...ENDSCAN command performs a similar function, but is more efficient.
Example
use patrons locate for event = "DREAM" do while found() display event, name, seats, seats * price continue enddo
Products
Recital Server, Recital