Appendixes

the argument name in the formal parameter list by the keyword VAR; otherwise, the argument is passed by value. Only variables can be passed by address. Expressions like A+B, where A and B are integer variables can be passed by value but cannot be passed by address.

Two basic types of variables are supported:

INTEGER and STRING

In the STRING, since the ASCII null character is internally used to indicate the end of the sequence, it cannot be part of the string. All other characters, including extended ASCII characters can be part of the string.

There are two types of conditional constructs:

IF and SWITCH

The IF statement is a two-way branching construct. The condition can be an arbitrary expression. The condition in the IF statement should evaluate to an integer or real. If the expression in the IF statement evaluates to non-zero, the control enters the THEN statement, otherwise control enters the ELSE statement.

The SWITCH statement is a multi-way branching construct. The type of conditional expression should be either INTEGER or STRING. The value of the conditional expression is matched against the constraints given in the CASE options, if the value matches a CASE option value, control enters that CASE option. If the values do not match any of the CASE options, and if a DEFAULT option is provided, control continues at the DEFAULT option; otherwise control continues at the statement after the ENDSWITCH. If control enters one of the CASE or DEFAULT statements, all the statements up to the next ENDCASE statement are executed. Each CASE or DEFAULT statement should be terminated by a matching ENDCASE keyword. The SWITCH statement should be terminated by a ENDSWITCH keywork. The DEFAULT statement can be placed anywhere within the scope of the SWITCH statement. There can be only one DEFAULT statement.

There are two types of iterative constructs:

FOR and WHILE

The FOR construct sets the loop control variable to an initial value. The control variable is checked for bounds, and if within bounds, the <statement_list> given is executed; otherwise the loop execution terminates. After each execution of <statement_list>, the control variable is incremented or decremented by a certain value. This is computed as follows: if the STEP expression is given it is the value of the expression, else it is 1. The control variable is incremented if TO is specified, and is decremented if DOWNTO is specified. After updating the control variable the bounds check is done again. The keyword ENDFOR is mandatory at the end of the loop.

The WHILE loop has an expression and a <statement_list>. The expression is evaluated and if the expression is non-zero the <statement_list> is executed; otherwise the loop execution terminates. The keyword ENDWHILE is mandatory at the end of the loop.

Operator Precedence:

Operators are listed in the order of precedence

Unary Operators :-!(unary minus, logical negation)

Binary Operators :*/ + _< > <= >= == ! = && II

All the operators are left associative. Expressions are evaluated completely; so care must be taken while writing expressions. For example, expressions like (a !=0 && b / a) would create run time error.

MTASR1-100

59

Page 59
Image 59
Multi-Tech Systems MTASR1-100 Two basic types of variables are supported, There are two types of conditional constructs