You are here: Commands > Search

Search

Menu: Found in the TOOLS menu

Use the Search command to locate:

A specified record number
The first record in a file meeting a specified condition
The first record in an indexed file that either meets or exceeds a specified key value, in which that value is a character string or character expression which may include references to fields or variables

Once the record is found, you can choose to perform calculations on it or compare its contents to that of another record.

Note: If you are using an indexed file with Search, you should know whether or not the index is conditional. A conditional index excludes certain records from the resulting View and the commands issued when it is in effect.

See Index for details.

See also Find, Locate and Seek.

Parameters

The Search command has the following command parameters:

Expression

Allows you to enter a record number or expression. You can enter an expression directly in the text box or select [Expression] to use the Expression Builder to build an expression. See Expression Builder for details.

Find Literal

Allows you to locate the first record in the indexed table that has an index key value equal to or greater than the specified value. If the specified key value is found, the View is positioned at that record. Otherwise, the message “No Index Matched Key” is displayed and the file is positioned at the first record with a key value greater than the specified value.

To specify a character string to be found, enter the string in the text box. The character string cannot contain leading blanks and must not be surrounded by quotes. It can be shorter than the index key, in which case Search only compares the index key value up to the length of the specified value and positions you at the first matching record.

Prerequisite

The table must be indexed on at least one character key field in ascending order. Other key fields can be non-character or in descending order, but are excluded from the search. For example, if the indexed key fields are ProdCls (character field) ascending, Loc (character field) ascending and QtyOH (numeric field) descending, you can only search based on ProdCls and Loc, although any listings of the file are also sorted in descending quantity order.

Locate If

Allows you to find the first record in the table that meets specified conditions. This option processes the file sequentially, until the first record meeting the condition is found or the end of the file is reached.

The search is sequential starting at the first record and does not rely on any predefined key fields. The processing speed is proportional to the size of the file and the location of the record in it.

To specify a condition, either enter it directly into the text box or click [Expression] to display the Expression Builder to help you build an expression.

See Expression Builder for details.

Locate Record

Allows you to find a specific record number in the file. If you select this option, enter the record number in the text box.

Seek Expression

This option operates the same as the Find Literal option, except Analyzer assumes that the specified value to be found is a character-type expression, rather than a literal character string.

For example, assume you want to find the first record that has a key value equal to the contents of variable X (which has a surname retained from earlier processing, such as SMITH). Simply enter the letter X into the text box and the file will be positioned at the first record with a key value of SMITH or the next greatest value, as appropriate.

If you want to find a simple character string, put quotes around the string. Leading blanks may be entered after the opening quotation mark.

Prerequisite

See the Find Literal prerequisite above.

Command Mode Syntax

For Locate Record and Locate If, see Locate.

For Find Literal, see Find.

For Seek Expression, see Seek.

Examples

To find record number 478 in an accounts receivable file use Search with the Locate Record option.

The Command Log indicates that record 478 has been located and the file is positioned at that record in your View. You can now perform further analysis on this record.

To scan a customer master file for a record in which the company’s name is “Island Trading”, use the Search command’s Locate If option. When there is more than one occurrence in the file, Analyzer positions the file at the first occurrence.

The Command Log indicates that the condition has been met by record 47 and Analyzer positions the file at that record in the View.

To View a list of customers based in New York (abbreviated NY) use the Search command’s Find Literal option. Ensure that the file is indexed on the character field representing the place of residence.

Analyzer positions the file at the first record for which it finds a match to the literal string “NY”. Because the file is indexed, all customers residing in NY are listed consecutively.

To achieve the same results, you could also:

Select Seek Expression in the Search dialog and enter ‘NY’ in the text box.
Select Locate If in the Search dialog and enter STATE=‘NY’ in the text box.