BASIC commands
PROGRAMMING MANUAL
117
R
e
vi
si
o
n
1
.0
3.2.163 IN
/i
Description
This structure controls the flow of the program based on the results of the con-
dition. If the condition is
TRUE
the commands following
THEN
up to
ELSEIF
,
ELSE
or
ENDIF
are executed. If the condition is
FALSE
and the command of
a subsequent
ELSEIF
substructre is
TRUE
, the commands of this substruc-
ture are executed. If all conditions are
FALSE
the commands following
ELSE
will be executed or the program will resume at the line after
ENDIF
in case no
ELSE
is included. The
ENDIF
is used to mark the end of the conditional block.
Note:
IF..THEN..ELSE..ENDIF
sequences can be nested without limit. For a
multi-line
IF..THEN
construction, there must not be any statement after
THEN
.
A single-line construction must not use
ENDIF
.
Arguments
•
condition_i
A logical expression.
•
commands
One or more BASIC commands.
Example
IF MPOS > (0.22 * VR(0)) THEN GOTO exceeds_length
Example
IF IN(0) = ON THEN
count = count + 1
PRINT "COUNTS = ";count
fail = 0
ELSE
fail = fail + 1
ENDIF
Example
IF IN(stop)=ON THEN
OP(8,ON)
VR(cycle_flag)=0
ELSEIF IN(start_cycle)=ON THEN
VR(cycle_flag)=1
ELSEIF IN(step1)=ON THEN
VR(cycle_flag)=99
ENDIF
Example
IF key_char=$31 THEN
GOSUB char_1
ELSEIF key_char=$32 THEN
GOSUB char_2
ELSEIF key_char=$33 THEN
GOSUB char_3
ELSE
PRINT "Character unknown"
ENDIF
See also
N/A
Type
I/O function
Syntax
IN(input_number [ ,final_input_number ])
IN
Description
The
IN
function returns the value of digital inputs.
•
IN(input_number, final_input_number)
will return the binary sum of
the group of inputs in range [
input_number
,
final_input_number
]. The
two arguments must be less than 24 apart.
•
IN(input_number)
will return the value of the particular input specified
by the parameter
input_number
.
Arguments
•
input_number
The number of the input for which to return a value. The range for this
parameter depends on the number of additional digital I/O connected
over the MECHATROLINK-II bus. If there are no digital I/O connected,
the range for this parameter is 0..31.
•
final_ input_number
The number of the last input for which to return a value. The range for
this parameter depends on the number of additional digital I/O connected
over the MECHATROLINK-II bus. If there are no digital I/O connected,
the range for this parameter is 0..31