Motion Coordinator Technical Reference Manual
Trio BASIC Commands 8-71
Program Loops and Structures
Example 2:
IF IN(0)=ON THEN
count=count+1
PRINT "COUNTS=";VR(1)
fail=0
ELSE
fail=fail+1
ENDIF
Note:
For a multi-line
IF..THEN
construction there must not be any statement after the
THEN
keyword. If there is the controller will assume it is a single line IF construc-
tion. The single line construction should not use
ENDIF
.
The
ELSE
sequence is optional. If it is not required the
ENDIF
is used to mark the
end of the conditional block.
NEXT
Type:
Program Structure
Description:
Used to mark the end of a
FOR..NEXT
loop. See
FOR
.
ON.. GOSUB
Type:
Program Structure
Syntax:
ON expression GOSUB label[,label[,...]]
Description:
The expression is evaluated and then the integer part is used to select a label from
the list. If the expression has the value 1 then the first label is used, 2 then the sec-
ond label is used, and so on. If the value of the expression is less than 1 or greater
than the number of labels then an error occurs. Once the label is selected a
GOSUB
is performed.
Example:
REPEAT
GET #3,char
UNTIL 1<=char AND char<=3
ON char GOSUB mover,stopper,change