WHILE
Syntax
WHILE (Condition, Expression)
Description
The WHILE function supports looping and takes two arguments: a condition that determines whether to continue looping and an expression to evaluate for each iteration.
Example
WHILE(&Balance < TARGET_BALANCE .AND. &Month < NUMMEMBERS(MONTHS),
INC(&Month);
INC(&Balance, AT(MONTHS, &Month, CA)));
IF(&Month <= NUMMEMBERS(MONTHS), &Month, #N/A)
This formula calculates the number of months required to accumulate a target balance.
The IF function returns the value of &Month, or an error code if the target balance is not achieved. Notice that it is not necessary to initialize &Balance and &Month because they are initialized to zero before the formula is evaluated.