613-518-1166 info@zimdatabases.com

ZIM Language Reference

LOCATE

< All Topics

Locates a particular member of a result set and makes it the current member.

Syntax

LOCATE [num] [set] [WHERE clause]

Parameters

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.

Comments

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.

Example

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”

output $located

compute all Employees where LastName=”Smith” and FirstName=”John” valuate (“”)

output $membercount

find all Employees where LastName=”Smith” and FirstName=”John”

output $setcount

All three of the preceding examples determine how many employees have the name John Smith.

while

locate DetroitSet where LastName=”Smith” and FirstName=”John”

if $located = 0

  return    % checks if done

endif

ProcessEmp ( )  % program to process this John Smith

endwhile

Each John Smith record in the designated set is processed.

 

See Also

BOTTOM

DOWN

NEXT

PREVIOUS

TOP

UP

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Table of Contents