BEE Script: if (condition) statement;
[else statement;]
or if (condition) { statement; ... }
[else { statement; ... }]
BEE Tag: <beeif "condition">
tag
...
[<beeelse>
tag
...]
</beeif>
Note: The condition is surrounded by a small bracket and therefore is taken literally. While you can (and sometimes need to) quote individual values in the condition, please do not quota the whole condition with double or single quote. Otherwise, the whole condition will be taken as a string (and will most likely to be evaluated to true unless it is blank or 0).
The "if" command starts a conditional block structure and therefore an "else" or a sequence of "elseif" tags can follow the conditional block.
The condition will be evaluated for any BEE Variables before the truth value is determined. Please note that variables are evaluated as macros and therefore one should bear in mind the logical expression syntax. In particular, you need to quote strings as required:
Example:
var num = 2;
var item = 'water melon';
if ({num} > 10) display 'We got plenty'; // Valid
// The condition will evaluate to (2 > 10)
if ('{num}' > 10) display 'We got plenty'; // Valid
// The condition will evaluate to ('2' > 10), which is OK.
if ('{item}' == 'lemon') display "Can't eat them"; // Valid
// The condition will evaluate to ('water melon' == 'lemon').
if ({item} == 'lemon') display "Can't eat them"; // Invalid
// The condition will evaluate to (water melon == 'lemon').
If the condition is blank, it will evaluate to false.
After the "if" command is executed, the following BEE Variables are made available:
result%if:istrue |
Set to 1 if the condition evaluates to true, or 0 otherwise |
result%if:condition |
Set to the condition after variable evaluation |
|