beautypg.com

3 iteration statements, 1 the maxl while statement, The maxl while statement – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 89

background image

otherwise
TRACE (“Error attribute ”)
end switch


The preceding code fragment shows how switch statements can be nested.
The switch statement that selects on the value of cmdName is executed only if attribute is
1. The case labels for menu selections, 1 (BG) and 2 (MO=1), associate with the inner
switch statement.

5.5.3

Iteration Statements

Iteration statements cause statements (or compound statements) to be executed zero
or more times, subject to some loop-termination criteria. When these statements are
compound statements, they are executed in order, except when either the break
statement or the continue statement is encountered. For a description of these
statements, see

The break Statement

and

The continue Statement

sections.

MAXL provides two iteration statements — while and for. Each of these iterates until
its termination expression evaluates to zero (false), or until loop termination is forced
with a break statement.

Syntax

iteration-statement :

while ( expression ) statements end while
for
identifier-variable=expression : [step- expression :] terminate-expression

statements

end for

5.5.3.1

Maestro

Software Manual

MAXL Program Language

MAN-MASSW (Ver. Q)

The MAXL while Statement

The while statement executes a statement repeatedly until the termination condition
(the expression) specified evaluates to zero.

The test of the termination condition takes place before each execution of the loop;
therefore, a while loop executes zero or more times, depending on the value of the
termination expression.

Syntax

while ( expression ) statements end while

Example:

while( attribute < 56)
attrbute=attribute+17

TRACE(“Attribute : %”, attribute)

end while

5-27