Difference between revisions of "LOCATE"

From Recital Documentation Wiki
Jump to: navigation, search
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
==Class==
 
Table Basics
 
 
 
 
==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 46: Line 42:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 
[[Category:Table Basics]]
 
[[Category:Table Basics]]
 
[[Category:Table Basics Commands]]
 
[[Category:Table Basics Commands]]

Latest revision as of 17:16, 11 November 2009

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