You are here: Commands > Seek

Seek

Use the Seek command to move directly to the first record in an indexed file containing a specified character search key.

This command can be issued only in command mode. For more information, see Issuing Commands.

Seek allows you to locate the first record in the indexed table that has an index key value equal to or greater than the value of a specified character expression. 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.

After the record is found, you may want to display or perform calculations on its contents. Alternatively, you may want to compare the contents of one record with that of another or of a variable.

A character-type expression may include references to fields or variables or can be a literal string. To use Seek to find a character string, the string must be surrounded by quotes.

When looking for values that contain leading blanks, you must use the Seek command or the Seek Expression option of the Search command. You can also use the Next and While parameters with Seek.

Note: The functionality of the Seek command is identical to the Seek Expression option of the Search command. Search is accessible through a dialog and as a result is more convenient to use. Use Search instead of Seek whenever possible. For more information, see Search.

Prerequisites

The table must be indexed on a character field in ascending order.

Command Mode Syntax

SEEK character-expression

character-expression indicates the value of the index key expression (in quotes if it is a simple character string) or the name of a field or variable which contains a character value.