Difference between revisions of "LOCATE"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 19: Line 19:
  
 
==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 34:
 
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 SCAN…ENDSCAN command performs a similar function, but is more efficient.
+
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.
  
  

Revision as of 11:40, 17 March 2009

LOCATE

Class

Fields and Records


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 Database Server, Recital Mirage Server, Recital Terminal Developer