... statements if condition1 true ...
[<ELSE[ ]IF condition2>
... statements if condition2 true ...]
... statements if both are false ...]
IF statement evaluates the given conditional expression.
If the result is true (i.e. nonzero), then the statements following the
<IF> tag are executed. If the result is false, those statements are
skipped and control falls to the next statement after the closing
ELSE clause may be present, in which case the
statements following the
<ELSE> tag are executed instead if the
result is false. If the
ELSE clause is another
statement, it can be made part of the
<ELSE> tag by using
<ELSEIF>. Thus, the left and right statements below are equivalent:
<IF $x eq 5> <IF $x eq 5>
X is five. X is five.
<ELSE> <ELSEIF $y gt 10>
<IF $y gt 10> Y is greater than 10.
Y is greater than 10. <ELSE>
<ELSE> X is not five and Y is <= 10.
X is not 5 and Y is <= 10. </IF>
ELSEIF clauses are used on the same value, a
statement (here) may be a clearer alternative.
The condition of an
IF statement can be simple or complex. A
simple condition is of the form arg1 op arg2, where each
arg is a variable or literal string, and op is one of the
neq: Does not equal
gt: Greater than
gte: Greater than or equal to
lt: Less than
lte: Less than or equal to
nmod: Not mod; true if
<IF $temp lt 32>
A SQL expression condition can be any valid Texis SQL
or may be used, or even
<IF $limit lt 5 and ($ans eq "correct" or $body like $query)>
You're under the limit, and either
have the correct answer or the text matches your query.
Variables should not be embedded inside a literal string, e.g.
"this is a $test". Literal string values should always be
quoted, or they may be misconstrued as non-existent SQL columns.
The results of some operators can depend on the original type of the values, e.g. comparison of integer vs. string values (see discussion under Variable Types, here).
If a variable contains more than one value in its current context
(i.e. outside a
LOOP), only the 0th (first) value is used.
An empty (no values) variable is considered an empty string.