Finds records that match specified conditions, producing a result set.


FIND [ num] [ setspec] [EVALUATE clause] [-> clause]


num The number of records to be found. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
If num is omitted, or less than 0, it defaults to ALL.
setspec The set specification that defines the records to be found. If omitted, the current set (if it exists) is used.


Sets found using the FIND command are not stored permanently; they exist only for the current application session or until a DISPOSE SET command is executed.

If the -> clause is omitted, a result set is still produced. The unnamed result set can be referred to as CurrentSet for as long as it remains the current set.

Changes made to a record in an EntitySet or relationship are reflected in the result set, and vice versa.

$ SetCount and $ MemberCount are assigned a value equal to the number of members in the result set found by the FIND command.


To find all employees whose last name is Smith, enter

find all Employees where LastName = "Smith" -> SmithSet

If you are working interactively at the command prompt, you could find it convenient to use the current unnamed result set when narrowing down a set of records. In the repeated FIND command, the second and third commands use the current set as their implicit setpsec:

> find Employees where Location = "Canada"
2019 selected
> find where LastName = "S"?
146 selected
> find where DeptNum = "D01"
7 selected

The name CurrentSet can also be used explicitly.

In application programs, you should explicitly name the result sets that you create with a FIND command. This technique is especially useful if you plan to compile a program that contains FIND commands:

procedure GetSet1 (a, b)
 if a=b
  find all Employees WorkIn Department -> KeepEmps
  find all Employees WorkIn Department \
    where LastName = a -> KeepEmps
 list all KeepEmps

You can use the FIND command to locate data, as shown in the following example:

find all Employees where LName = fEmployees.LastName
if $ setcount > 0
 list all
 output "Nobody who works here is named: " fEmployees.LastName

You can also use FIND with forms as shown below:

find fItems where fItems.Qty > 0  % find values entered


Related Topics