Developing Apama Applications > Apama EPL Reference > Statements > Compound statements > The for statement
The for statement
The for statement is used to iterate over the members of a sequence and execute the enclosing statment or block once for each member.
ForStatement
Rule components
The expression, which must produce a reference to a sequence or a dictionary’s key, is evaluated. Then the IterationVariable is assigned a value successively obtained from each element of the sequence, starting with the first, and if the last sequence entry has not been reached, the statement that forms the loop body is executed.
The IterationVariable’s type must match the type of the sequence elements.
The loop body is either a single Statement or a Block.
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 sequence size is tested to determine if the last entry has been reached. If it has not, then the loop body is executed. 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.