Updated March 2017; see History
++IF <constant expression>
...
{++ELIF <constant expression>
...{++ELSE
...
++ENDIF
The statement " ++IF <constant expression> " evaluates the specified expression and compiles the following statements if the expression is equivalent to TRUE. Constant expressions are a subset of regular BASIC expressions, made up only of defined symbols (constants) and literals (i.e. no variables), and a limited set of pre-defined functions and operators:
• | All arithmetic operators (+, -, /, *, **, ^, MOD) |
• | All logical operators (AND, OR, NOT) |
• | Comparison operators (<, >, <=, >=, ==, <>, #) |
• | All bitwise operators (AND, OR, NOT, NOR, XOR) |
• | Arithmetic functions: int(), fix(), abs(), min, max |
• | Scientific functions: exp(), sgn(), sqr(), sin(), cos(), tan(), atn(), fact() |
• | String functions: +, left(), mid(), right(), [a, b], len(), instr(), asc(), chr(), str(), val(), rtrim(), edit(), strip(), pad() |
• | File functions: lookup() |
++ELIF <constant expression> is equivalent to ++IF <constant expression> except is only evaluated if the preceding ++IF or ++ELIF expression(s) were false. See example below.
Examples
++IF APPVER > 3
<statements>
++ENDIF
++IF SITE_NAME$ = "MARS"
<statements>
++ELIF SITE_NAME$ = "JUPITER"
<statements>
++ELIF SITE_NAME$ # LOCAL_PLANET$
<statements>
++ENDIF
++IF (APPVER > 3) AND (LOOKUP("xyz.bsi") # 0)
<statements>
++ELSE
<statements>
++ENDIF
Note that the above examples are only valid if APPVER, SITE_NAME$, and LOCAL_PLANET$ are DEFINE'd symbols. Variables would not be acceptable because their values are not constant from the compiler's perspective. The LOOKUP expression is acceptable as long as the filename is constant, i.e. a literal string as in the example, or a DEFINEd symbol.
History
2017 March, A-Shell 6.4.1546, compiler enhancement (797): maximum nesting levels for ++INCLUDE and ++IF conditions increased from 20 to 40. Improve messaging/recovery for the overflow condition.