Next

Command group Flag affected Reversible Execute on client Platform(s)
Finding data YES YES NO All

Syntax

Next on field-name ([Exact match][,Use search])

Options

Exact match If specified, the index value of the field in suitable records must equal the current value
Use search If specified, the command uses the current search to select data

Description

This command locates the next record using the current find table. The Next command works in the same way as the corresponding option on the Commands menu but with no redraw, allowing you to work through a file. It is usually used after a Find command which creates a find table of records.

If the Index field, Exact match and/or Search option used in the Next is incompatible with the preceding Find, a new find table is built. Normally, the parameters in this command are left blank so that the current find table is used.

If the Next command does not follow a Find, a find table is built for the current main file before doing the Next.

If an indexed field is specified, Next on SU_NAME for example, the find table is just the index order for the field. The Use search option creates a find table for the current main file in which the search specification is implicitly stored. Thus, changes to the search do not affect the find table once it is created.

Once the next record is located, the main and connected files are read into the current record buffer.

An error occurs whenever a Next on FIELD command is performed on a non-indexed field or if the field is not in the main file or its connected files.

If the next record is found, the flag is set; if not, it is cleared.

If the Exact match option is chosen, the next record is loaded where the index value of the specified field matches the current value.

If you use Next with a search, it builds a find table if necessary and finds the next record listed on the find table which meets the search criteria.

Example

# Add 5% to all account balances
Find first on fAccounts.Code
While flag true
  Calculate fAccounts.Balance as fAccounts.Balance+((fAccounts.Balance/100)*5)
  Update files
  Next
End While