All BASIC commands
Section 4-2
172
4-2-133 IF..THEN..ELSE..ENDIF
/i
Arguments
•
value
Any BASIC floating point variable or parameter.
•
n
The byte number (0 - 3) to be extracted.
Example
a=MPOS AXIS(2)
byte0 = IEEE_OUT(a, 0)
byte1 = IEEE_OUT(a, 1)
byte2 = IEEE_OUT(a, 2)
byte3 = IEEE_OUT(a, 3)
See also
N/A
Type
Program control command
Syntax
IF condition_1 THEN commands {ELSEIF condition_i THEN
commands} [ ELSE commands ] ENDIF
IF condition_1 THEN commands
Description
This structure controls the flow of the program based on the results of
the condition. 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
substructure is
TRUE
, the
commands of this substructure 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
Summary of Contents for SYSMAC CJ Series
Page 2: ......
Page 70: ...Specifications Section 2 4 58...
Page 84: ...FINS commands Section 3 4 72...
Page 148: ...All BASIC commands Section 4 2 136 AXIS 1 AXIS 0...
Page 370: ...Section 358...