If true

Purpose: Comparison statement.

 if-true <comparison>
     <any code>
 [
 else-if <comparison>
     <any code>
 ] ...
 [
 else-if
     <any code>
 ]
 end-if

if-true statement will evaluate a <comparison> and if true, it will execute <any code> that immediately follows; if false, it will evaluate the optional following <comparison> in else-if statement, and if true it will execute <any code> that immediately follows it; and so on; if none of the comparisons are true, then an optional <any code> following else-if statement will execute; regardless of which <any code> executes (or if any does), the execution will continue after end-if.

There can be only one "else-if" statement without a condition, and it must be the last one.

<comparison> is
If "equal" or "not-equal" clause is used, a comparison succeeds if <boolean> is equal or not equal than <check boolean>, respectively.
Multiple comparisons
For convenience, multiple <comparisons> can be connected by either "and" or "or" clause, but not both in the same <condition> (in order to keep comparisons readable; see boolean-expressions for constructing more involved boolean expressions). "and" clause uses logical AND to connect <comparisons> and it succeeds if all <comparison>s succeed. "or" clause uses logical OR to connect <comparisons> and it succeeds if at least one <comparison>s succeeds (if such a <comparison> is found, the following ones are not checked).
Nesting
if-true can be nested, which can be up to 30 levels deep.
Examples
 %% /if-test public
     get-param inp
     if-true inp equal "1"
         @Found "1" in input
     else-if inp equal "2"  or inp equal "3"
         @Found "2" or "3" in input
         get-param inp_num
         string-number inp_num to num
         if-true num equal 4
             @Found 4 in more input
         else-if num equal 5  and  inp equal "4"
             @Found 5 in more input and "4" in input
         else-if
             @Something else
         end-if
     else-if
         @Found something else
     end-if
 %%

<string>, <number> and <boolean> can be expressions, for instance:
 set-string str1="one"
 set-string str2="two"
 if-true str1+" "+str2 not-equal "one two"
     @It can't be true!
 end-if
 ...
 set-bool b1 = str1 not-equal "one"
 set-bool b2 = str2 equal "two"
 if-true b1 && b2 equal false
     @It is true!
 end-if
 ...
 set-number n1 = 20
 if-true n1+10 equal 30 and !b1 equal true and str1 equal "one"
     @It is true!
 end-if



Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.