You are here: Command Parameters > While

While

While is a scope parameter that causes a command to be executed while a condition is true. While causes command processing to terminate as soon as the specified test evaluates as false or the end of the file is reached.

While is dependent on current record position. To begin processing, the current record must evaluate as true. While is typically used with blocks of items in which the condition evaluates as true.

If the end of the file was reached during execution, the record position will be reset to record 1.

The While parameter can also be used in conjunction with the If, Next or First parameters.

After execution of a command containing While and If or First, the record position is determined by the While parameter.

After execution of a command in which both While and Next are specified, the record position is determined by the first of the two clauses to terminate processing.

Note: Because While can cause an early termination of processing, it cannot be specified within a Group command, although it can be used as a parameter in the outermost Group command.

Command Mode Syntax

WHILE Test

In the following example the Count command is executed, starting at the current record position, on the Quantity on Hand field as long as the Product Class is 07:

COUNT WHILE ProdCls = "07"

As soon as the command fails the While test, processing stops and the record position is set at the first record that failed the test.

Command Dialog Box

The While parameter is available by clicking the [More] button in most command dialogs.

In the “Limit Processing To” group box, simply enter the While condition directly in the While text box or click [Expression] to display the Expression Builder. For more information, see Expression Builder.