ph_forloopwinc PowerHome formula function
Description
Evaluates a formula expression a specified number of times while incrementing a local variable.
Syntax
ph_forloopwinc ( formula, n, n, n, local )
Argument |
Description |
formula
|
A string which contains the formula expression you would like to have evaluated.
|
n
|
A double representing the starting value of the for loop.
|
n
|
A double representing the ending value of the for loop.
|
n
|
A double representing the increment value of the for loop.
|
local
|
An integer representing the number of local variable to be incremented.
|
Return value
Integer. Returns a 0 when the loop is completed. If the increment value is 0, then a value of 1 is returned. If the local variable specified is out of range, then 2 is returned.
Usage
Use the ph_forloopwinc when you want to evaluate a formula a known number of times. The formula will be evaluated as long as the starting value is less than or equal to the ending value if the increment is a positive number. The formula will be evaluated as long as the starting value is greater than or equal to the ending value if the increment is a negative number.
When the function is first executed (prior to the formula being evaluated), the start value will be copied into the local variable. The formula will then be evaluated. The local will then be incremented by the increment value. If the local is still between the start and end values, then the formula will be evaluated again with the whole process repeating itself until the local is no longer between the start and end values.