Locates a particular member of a result set and makes it the current member.
LOCATE [num] [set] [WHERE clause]
|num||The number of records to be located. Num can be
an integer constant (e.g., 15, 200);
a variable, form field, menu item, or formal parameter that evaluates to an integer;
the word ALL.
The default value for num is 1.
|set||The name of a result set. If not specified, the current set (if it exists) is used.|
LOCATE starts searching at the current member of the set. The last member located becomes the current member of set. The system variable $Located is set to the number of members located, indicating the number of members in the result set.
The WHERE clause can be used to logically limit the members located.
find all employees where location=”Detroit” -> DetroitSet
locate DetroitSet where FirstName=”John” and LastName=”Smith”
locate 2 DetroitSet where FirstName=”John” and LastName=”Smith”
Because LOCATE starts with the current member of any set it searches, the current member after the last LOCATE command is the third record containing the name John Smith.
find all Employees where LastName=”Smith” -> Smiths
locate all where FirstName=”John”
compute all Employees where LastName=”Smith” and FirstName=”John” valuate (“”)
find all Employees where LastName=”Smith” and FirstName=”John”
All three of the preceding examples determine how many employees have the name John Smith.
locate DetroitSet where LastName=”Smith” and FirstName=”John”
if $located = 0
return % checks if done
ProcessEmp ( ) % program to process this John Smith
Each John Smith record in the designated set is processed.