Conditionals and Loops
The if statement supports both simple and complex logical operations. if, else, and else if branches are supported with and without open and close braces ('{' and '}'). Unlike many programming languages, a semicolon is required at the end of the final close brace (if used).
if (<expression>)
<expression>;
else if (<expression2>)
<expression>;
else
<expression>;
if
(<expression>)
{
<expression1>;
<expression2>;
};
The ? operation can be used to define a simple if operation, and when combined with a : can include an else clause. The true and false branches each allow a single expression.
<expression> ? <true expression> [: <false expression>]
If no : or <false expression> is included, the original expression is returned. For example:
0
? 100, yields 0
1 ? 100, yields 100
(1==1) ? 100 : 200,
yields 100
(1==0) ? 100 : 200,
yields 1000
Note: Users must pay attention to operator precedence. The statement "1==1 ? 100 : 200" yields 0 since it is interpreted as "1==(1 ? 100 : 200)", and 1 == 100 is false or 0.
The switch statement resembles the C/C++ switch statement with the following exceptions:
The closing brace must include a semicolon
Users cannot consolidate expressions under multiple
case statements. The following is not
supported:
case 0x01:
case 0x02:
<expression>;
break ;
Case statements are not checked for uniqueness.
switch
(<expression>)
{
case <expression1>:
<expression1a>;
<expression1b>;
break;
case
<expression2>:
<expression2a>;
<expression2b>;
break;
case
<expression3>:
<expression3a>;
<expression3b>;
break;
default:
<expression4a>;
<expression4b>;
break;
};
While and for loops resemble the C/C++ constructs, but with the following exceptions:
"break" and "continue" statements are not supported
The ending brace (if used) must include a trailing semicolon
Loops and expression aborted on error
while
<expression1>
<expression2>;
while
<expression1>
{
<expression2>;
<expression3>;
};
for
(<init expression>; <control expression>; <post expression>)
<expression>;
for
(<init expression>; <control expression>; <post expression>)
{
<expression1>;
<expression2>;
};
Operations: Arithmetic, Bitwise, Logical, and Precedence
Functions: Arithmetic and Document