... 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.
For ease of compliance with the HTML-like syntax of Vortex, quote and operator translation will occur before the expression is parsed by SQL: Double quotes that denote strings will be mapped to single quotes, and single quotes in strings will be escaped to two single quotes. And the following operators will be mapped:
In addition, if the expression is operand
nmod operand, it
will be mapped to (operand
% operand) = 0, for legacy
support of the
nmod operator, which is deprecated (use SQL
<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).
syntaxversion pragma (here)
to enable deprecated legacy version 7 parsing behavior for older
scripts, such as support for simple Vortex expressions.
arrayconvert (here) applies to
all variables in
IF expressions in version 8 and later,
IF expressions are now handled by SQL.
An empty (no values) variable is considered an empty string.