Developing Apama Applications > Apama EPL Reference > Statements > Compound statements > The while statement
The while statement
The while statement is used to repeatedly evaluate a boolean expression and execute a block as many times as the expression result is found to be true.
WhileStatement
Rule components
The expression, whose result type must be boolean, is evaluated and if the result is true, the block is executed. Control then transfers to the top of the loop and the expression is evaluated again. When the expression result is false, control is transferred to the next statement following the while statement.
The body of the loop must be a block; it must be inside curly braces.
Within the loop body, the break statement can be used to cause early termination of the loop by transferring control to the next statement after the loop body. The continue statement can be used to transfer control to the end of the body, after which the expression will be evaluated again and the loop body executed if the expression result is true. The return statement can be used to terminate both the loop and the action that contains it.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.