While
General Control Statement
The While statement repeatedly executes an action during a specified Boolean condition remains true.
Syntax
While <Boolean expression> Do <statement block>
Syntax Examples
While
{
Array1[n] <> 10
}
Do
{
Inc n
}
While
{
FreeCap(Loc1) > 5
}
Do
{
Inc Var2, 5
Wait 5 sec
}
Parameters
<Boolean expression>
The true or false condition to evaluate. Statement is the action that is repeatedly executed while the Boolean expression remains true. The Boolean expression is evaluated for each iteration of the statement.
Parameter Examples
Suppose you have a model where your Flow's second half moves a lot faster than the first half. For this reason, you want to let 100 Entities pile up in the last Location of the Flow's first part (a Storage Location) before allowing them to the second part, since you save money by not running the second half of your model during that time. You then want the Entities to pass through the Storage Location freely, since your model's second half is fast enough to process the 100 Entities and all the new Entities that come after without falling behind. To achieve this result, define a Variable to represent how many Entities are in your Storage Location, vStorage. Next, define the statements...
Inc vStorage
While vStorage < 100 Do Wait 10 min
...in the Storage Location Logic. Every time an Entity enters the Storage Location, the Inc statement increases the value of vStorage. While vStorage is less than 100, the While loop continues to execute, keeping the Entities in the Storage Location due to the Wait statement. Once the value of vStorage is 100 or greater, the While loop no longer execute and the Entities pass through the Storage Location directly after being processed.