JP #Loop,COUNT<10
Jump to #Loop if the variable, COUNT, is less than 10
JS #MOVE2,@IN[1]=1
Jump to subroutine #MOVE2 if input 1 is logic level high. After
the subroutine MOVE2 is executed, the program sequencer returns
to the main program location where the subroutine was called.
JP #BLUE,@ABS[V2]>2
Jump to #BLUE if the absolute value of variable, V2, is greater
than 2
JP #C,V1*V7<=V8*V2
Jump to #C if the value of V1 times V7 is less than or equal to the
value of V8*V2
JP#A Jump
to
#A
Using If, Else, and Endif Commands
The RIO provides a structured approach to conditional statements using IF, ELSE and ENDIF commands.
Using the IF and ENDIF Commands
An IF conditional statement is formed by the combination of an IF and ENDIF command. The IF command
has arguments of one or more conditional statements. If the conditional statement(s) evaluates true, the
command interpreter will continue executing commands which follow the IF command. If the conditional
statement evaluates false, the RIO will ignore commands until the associated ENDIF command is executed
OR an ELSE command occurs in the program (see discussion of ELSE command below).
Note:
An ENDIF command must always be executed for every IF command that has been executed.
Using the ELSE Command
The ELSE command is an optional part of an IF conditional statement and allows for the execution of
commands only when the argument of the IF command evaluates False. The ELSE command must occur
after an IF command and has no arguments. If the argument of the IF command evaluates false, the RIO will
skip commands until the ELSE command. If the argument for the IF command evaluates true, the RIO board
will execute the commands between the IF and ELSE commands.
Nesting IF Conditional Statements
The RIO allows for IF conditional statements to be included within other IF conditional statements. This
technique is known as 'nesting' and the RIO allows up to 255 IF conditional statements to be nested. This is a
very powerful technique allowing the user to specify a variety of different cases for branching.
Command Format - IF, ELSE and ENDIF
Function
Condition
IF conditional statement(s)
Execute commands proceeding IF command (up to ELSE command)
if conditional statement(s) is true, otherwise continue executing at
ENDIF command or optional ELSE command.
ELSE
Optional command. Allows for commands to be executed when
argument of IF command evaluates not true. Can only be used with
IF command.
ENDIF
Command to end IF conditional statement. Program must have an
ENDIF command for every IF command.
Example using IF, ELSE and ENDIF:
Instruction
Interpretation
#TEST
Begin Main Program "TEST"
#LOOP
Begin loop inside main program
58 Chapter 5 Programming
RIO-47xxx
Содержание RIO-47**0
Страница 2: ......
Страница 93: ...RIO Dimensions RIO 471xx Units in centimeters RIO 47xxx Appendix 87...
Страница 94: ...RIO 472xx Units in millimeters 88 Appendix RIO 47xxx...
Страница 107: ...Internal 56 64 Zero Stack 53 RIO 47xxx Index 101...