ModL supports a full complement of structured programming control statements. In this list, "boolean" evaluates to true or false. STATEMENTS means either a single “statement;” or multiple statements grouped by braces:
{
statement;
......
statement;
} // note no semicolon here
Returns are ignored, and statements may use several lines. The control statements (in alphabetical order) are:
• ABORT
Stops the current message handler.
ABORT;
• BREAK
Immediately exits an enclosing FOR, WHILE, DO, or SWITCH statement.
BREAK;
• CONTINUE
Immediately sends control to the next iteration of an enclosing FOR, WHILE, or DO loop.
CONTINUE;
• DO-WHILE
Repeats the statement while the expression is true; tests at the end of the loop.
DO
STATEMENT; // see definition of multiple statements above
WHILE (boolean); // Note semicolon
• FOR (BASIC variation, see C variation below)
FOR id = init TO top STEP increment
STATEMENT;
or
FOR id = init TO top
STATEMENT;
• FOR (C variation, see BASIC variation above)
Lets you set the initial value, continuing boolean condition, and action to take.
FOR (init_assignment; boolean; incr_assignment)
STATEMENT; // see definition of multiple statements above
• GOTO
Supported only within a message handler or user defined function. Control is unconditionally transferred to the statements after the label.
GOTO label;
...
label: //note the colon after the label
...
• IF
Used for boolean comparisons
If (boolean)
STATEMENT; // see definition of multiple statements above
• IF-ELSE
Used for boolean comparisons if you have two paths to choose from
If (boolean)
STATEMENTA; // see definition of multiple statements above
else
STATEMENTB; // see definition of multiple statements above
• RETURN
Used to exit message handlers and user-defined functions.
RETURN;
or
RETURN(value or expression);
• SWITCH
Used to check values against integer constants and act on those cases.
SWITCH (expression)
{
CASE integerConstant:
zero to many STATEMENTS;
BREAK;
CASE integerConstant:
zero to many STATEMENTS;
BREAK;
DEFAULT:
zero to many STATEMENTS;
BREAK;
}
• WHILE
Repeats the statement while the expression is true; the expression is evaluated at the beginning of the loop.
WHILE (boolean) // Note no semicolon
STATEMENT; // see definition of multiple statements above