<continue>
Syntax
<continue/>
Attributes and Elements
Description
BPL syntax permits any element that can contain a sequence of activities—<case>, <default>, <foreach>, <false>, <sequence>, <true>, <until>, or <while>—to contain a <continue> element if desired.
The <continue> element allows the flow of control to jump to the next iteration of a loop, without completing the remaining operations inside the current iteration. For example:
<foreach property="P1" key="K1">
//...do various things...
<if condition="somecondition">
<true>
<continue/>
</true>
</if>
//...do various other things...
</foreach>
In the above example, it is the <true> element that contains the <continue> element. However, the loop affected by this <continue> is actually the containing <foreach> loop.
The example works as follows: If on some pass through this loop, the <if> element finds “somecondition” to be true (that is, equal to the integer value 1) then the flow of control passes to the <true> element inside the <if>. Upon encountering the <continue> element, execution halts the current pass through the <foreach> loop, proceeds to the next item in the collection (if there is a next item), and begins processing that next item from the beginning of the loop.
Loop activities that you might want to modify by using a <continue> element include <foreach>, <until>, and <while>. The effect of <continue> for each type of loop element is to halt the current pass through the loop, jump to the condition test for the loop, and allow that test and the type of loop to determine what to do next: continue looping, or exit the loop, as normal for that type of loop. For example:
Containing Loop | Behavior of <continue> |
---|---|
<foreach> | Test for the next item in the collection. If an item is found, begin processing it from the top of the loop. However, if there are no more items in the collection that match the test condition, exit the loop. |
<until> | Jump to the condition test at the bottom of the loop. If the condition is true, exit the loop; if false, execute the statements in the loop. |
<while> | Jump to the condition test at the top of the loop. If the condition is true, exit the loop; if false, execute the statements in the loop. |