Apama 10.15.0 | Developing Apama Applications | Developing Apama Applications in EPL | Defining What Happens When Matching Events Are Found | Defining conditional logic with the if statement
 
Defining conditional logic with the if statement
EPL supports conditional if and if ... else statements.
An if statement is followed by a boolean expression followed by an optional then keyword followed by a block. A block consists of one or more statements enclosed in curly braces, { }. If the boolean expression is true, the contents of the block are executed.
The boolean expression must evaluate to the boolean values true or false.
The if statement can be optionally followed by an else keyword and a second block. This second block is executed if the boolean expression is false. Instead of the else block, a single if statement, not enclosed in braces, may be used.
EPL example:
if floatVariable > 5.0 {
integerVariable := 1;
} else if floatVariable < -5.0 {
      integerVariable := -1;
} else {
      integerVariable := 0;
}