8-72 Trio BASIC Commands
Program Loops and Structures
Trio Motion Technology
ON.. GOTO
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
GOTO
is
performed.
Example:
REPEAT
GET #3,char
UNTIL 1<=char and char<=3
ON char GOTO mover,stopper,change
REPEAT.. UNTIL
Type:
Program Structure
Syntax:
REPEAT commands UNTIL condition
Description:
The
REPEAT..UNTIL
construct allows a block of commands to be continuously
repeated until a condition becomes
TRUE
.
REPEAT..UNTIL
loops can be nested
without limit.
Example:
A conveyor is to index 100mm at a speed of 1000mm/s wait for 0.5s and then repeat
the cycle until an external counter signals to stop by setting input 4 on.
cycle:
SPEED=1000
REPEAT
MOVE(100)
WAIT IDLE
WA(500)
UNTIL IN(4)=ON