- ⌂ Flow Control
- Directives
#IF
Sequentially evaluate a set of conditions and execute the code after the first condition that evaluates to TRUE up to the next condition (#ELSEIF or #ELSE) or #ENDIF. If an #ELSE is present and all other preceding conditions do not evaluate to TRUE, the code after the #ELSE will be executed. Each condition is a cTemplate expression and/or cScript expression.
Prototype
#IF(Condition1) ... #ELSEIF(Condition2) ... #ELSE ... #ENDIF
Parameters
- Condition - cTemplate expression and/or cScript expression that evaluates to TRUE or FALSE.
Example
#ASSIGN($A, 3)
#IF($A == 1)
A is one.
#ELSEIF($A >= 2 || $A <= 6)
A is between 2 and 6.
#ELSE
A is an unrecognized value.
#ENDIF
Result
First, the #IF($A == 1) condition will evaluate to FALSE, then the #ELSEIF($A >= 2 || $A <= 6) condition will evaluate to TRUE, so "A is between 2 and 6" will be output and the subsequent #ELSE will be skipped.