else
Defines an additional execution path for an if block.
Syntax
else
Input
N/A
Example
- Example 1
- Template:
{numer = 5} {denom = 4} {if(numer == 0)} The numerator is 0, so the result is 0. {elseif(denom == 0)} The denominator is 0, so a result is impossible. {else} The result is:{numer/denom}. {endif}
- Example 2
- Template:
{x = 8} {y = 4} {if(x % y)} The remainder is {x % y}. {else} {x} is a multiple of {y}. {endif}
Comments
The else statement is used in conjunction with if and elseif statements. If all other conditional tests fail (evaluate as false), the statements following the else statement are executed. Execution continues until an endif statement is reached.
Only one else statement can be used within an if block. If an if block contains elseif statements, the else statement follows the last elseif.