LOCATE command

Used to search for the first record that meets a specified condition, or moves to a specified record number.

Syntax

LOCATE {<IF test> <WHILE test> <FIRST|NEXT range>|RECORD num}

Parameters

IF test

Optional. Specifies a condition that must be met. The command is only executed on records that pass the test.

WHILE test

Optional. Specifies that the command should only be executed while a condition is true. The command processing terminates as soon as the specified test evaluates as false, or the end of the table is reached.

FIRST | NEXT range

Optional. Specify FIRST to start processing at the first record or NEXT to start processing at the currently selected record. Use the range value to specify the number of records to process.

RECORD num

Specifies the record number to locate.

Remarks

The LOCATE command is not restricted to working on indexed tables, as the FIND and SEEK commands are. The LOCATE command may be significantly slower than the FIND and SEEK commands because it must search through each record in the table sequentially. The command starts the search at the first record (unless you specify the WHILE or NEXT parameters in the command). The processing time required depends on the size of the table and the location of the record in it.

Example

a. Locating the first record that meets a condition

The following example illustrates how you could use the LOCATE command to locate the first record where the Department value is 08, and the table is sorted by Department.

LOCATE IF Department = "08"

ACL selects the first record that meets the condition.

b. Locating a record by record number

The following example illustrates how you can use the LOCATE command to move to a particular record in a table.

LOCATE RECORD 50



(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback