Bungee Logic : Statement : While Iteration
Back to Bungee Logic Statements
Contents |
[edit] Description
A pre-test loop that continues iterating as long as the specified expression is satisfied.
Warning All Bungee Iteration constructs (for, while, and collection) share certain behaviors that are important to understand to avoid subtle bugs. In particular, each iteration construct has a set of Intrinsic Variables that are provided for programming convenience and to give control over the loop. These Intrinsic Variables must not be deleted or renamed, and should only be modified as documented. Also, variable initializers declared in the loop body are run only once, rather than once per iteration as you might have expected. For the gory details, see Iteration Basics.
[edit] Syntax
while (condition) { }
Where:
condition Is a site designating an expression that evaluates to true or false.
[edit] Logic
While loops look like this:
while (CONDITION)
{
var boolean StopIterating;
// Your code goes here
}
The statement block executes repeatedly, as long as StopIterating is false and CONDITION is true. CONDITION is checked before every iteration, so it is possible for the loop not to execute at all. The loop can be terminated even if CONDITION is true—this can happen if StopIterating is set to true, if a return statement is executed, or if an error is propagated out of the loop. Setting StopIterating to true does not cause the loop to exit immediately. Instead, as the next iteration begins, StopIterating is tested; if it is true, then the loop will terminate.
Bungee Logic does not provide a break statement, nor does it have a continue statement.
The CONDITION may be any site (a Var, Path, Expression, etc), and it is evaluated each time a new iteration is about to begin.
[edit] Error Handling
-None-
[edit] Intrinsics
Variables
- StopIterating — Setting this to true will terminate the iteration after the current loop finishes.
[edit] Properties
- Expression — A site that designates the CONDITION to be evaluated prior to each iteration of the loop.
- Reverse Iterate — Specifies whether the iteration proceeds in reverse order (from end to beginning).
- Maximum Iterations —The maximum number of times to repeat the loop.
Tab Title Bar
- Comment Out — Comments out the entire section of code.
- Set Breakpoint — Sets a breakpopint for debugging purposes.