Constrained_Find

See Also: Constraints, Constrain, Constrained_Clear, Constraint_Set, Constraint_Validate, Find, Found, OnConstrain

Purpose

To find records within the constraints in the current constraint set.

The DataDictionary class provides superior functionality that replaces the need for this command in some cases.

Syntax

Constrained_Find {mode} {table} by {-1 | recnum | Index#}

Where {table} is the name or filelist number of a database table; and {mode} must be one of LT, LE, EQ, GT, GE, FIRST, LAST or NEXT.

When the last argument is -1, the index to use will be determined automatically from the constraints in force themselves.

What it Does

Constrained_Find finds records that qualify under the current constraint set according to the find {mode} (First | Last | Next | LT | LE | EQ | GE | GT), in the table and index specified. A Relate command is then performed to find all related records (according to which records in {table} may also be constrained).

Constrained_Find next respects the direction (GT, LT), table, and index of the last Constrained_Find or Constrained_Clear command executed for the current constraint set.

Open Vendor

Constraint_Set 1

Constrain Vendor.State Between "CA" and "CT"

Constrain Vendor.Name Matches "D*"

Constrained_Find First Vendor By 1

 

While (Found)

    Showln Vendor.Name

    Constrained_Find Next

Loop

The above program will print the name field for every vendor record whose state field has a value between "CA" and "CT", and whose name field starts with a "D". Since index one is based on the name field, only the records with name starting with D will be scanned.

A Constrained_Find executed with no constraint set current behaves exactly like a(n unrestricted) Find command.

Constrained_Find sets the Boolean expressions Found and Finderr differently from the way the Find Command does. Constrained_Find always fills the record buffer when a record can be found, but Found becomes TRUE, only if the record satisfies the constraint set in effect. Found becomes FALSE if the record fails to satisfy the requirements of the constraints.

Notes