5 statements, 1 labeled statements, 1 using labels with the goto statement – ElmoMC Multi-Axis Motion Controller-Maestro User Manual

Page 86

Advertising
background image

5.5

Statements

MAXL statements are the program elements that control how and in what order
objects are manipulated.

MAXL statements are executed sequentially, except when an expression statement, a
selection statement, an iteration statement, or a jump statement specifically modifies
that sequence.

Syntax

statement

:

declaration-statement

labeled-statement

expression-statement

selection-statement

iteration-statement

jump-statement

5.5.1

Labeled Statements

To transfer program control directly to a given statement, the statement must be
labeled.

Syntax

labeled-statement

:

##identifier

statements

case (

expression)

statements

otherwise

statements

5.5.1.1

Maestro

Software Manual

MAXL Program Language

MAN-MASSW (Ver. Q)

Using Labels with the goto Statement

The appearance of an identifier label in the source program declares a label. Only a
goto statement can transfer control to an identifier label. The following code fragment
illustrates use of the goto statement and an identifier label to escape a nested loop:

Syntax

goto labeled-statement
labeled-statement

:

Example:

for ( i = 0 : 2 : 20 )
for( j = 2 : 16 )
if( i > j+10)
goto ##label
end if
end for
end for


## label
I=0

A label cannot appear by itself but must
always be attached to a statement.

The label has function scope and cannot
be re-declared within the function.
However, the same name can be used as a
label in different functions.

5-24

Advertising