Galil Motion Control DMC-21 5 Series User Manual page 93

Table of Contents

Advertisement

Using the ELSE Command
The
command is an optional part of an IF conditional statement and allows for the execution of command
ELSE
only when the argument of the
command and has no arguments. If the argument of the
commands until the
ELSE
execute the commands between the
Nesting IF Conditional Statements
The DMC-21x5 allows for IF conditional statements to be included within other IF conditional statements. This
technique is known as 'nesting' and the DMC-21x5 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
COMMAND
IF
(conditional statements)
ELSE
ENDIF
Example using IF, ELSE and ENDIF:
#test;
II,,3;
MG
"WAITING FOR INPUT 1,
INPUT
2";
#loop;
WT
10;
JP
#loop;
EN;
#ININT;
WT
50;
IF
(@IN[1]=0);
IF
(@IN[2]=0);
MG
"INPUT 1 AND INPUT 2
ARE
ACTIVE";
ELSE;
MG
"ONLY INPUT 1 IS
ACTIVE";
ENDIF;
ELSE;
MG
"ONLY INPUT 2 IS
ACTIVE";
ENDIF;
#wait;
JP
#wait,((@IN[1]=0) |
(@IN[2]=0));
RI
0;
Chapter 7 Application Programming ▫ 88
command evaluates False. The
IF
command. If the argument for the
and
command.
IF
ELSE
Execute following commands if conditional statements are true,
otherwise continue executing at
Execute following commands if conditional statements are false,
optional command
Command to end IF conditional statement
'program label
'enable input interrupts on Inputs 1 and 2
'message
'label for endless loop
'wait
'endless loop
'end of main program
'Input Interrupt Subroutine
'wait
'IF statement based on input 1
'2nd IF statement if 1st IF is true
'message if 2nd IF is true
'ELSE for 2nd IF statement
'message if 2nd IF is false
'end of 2nd IF statement
'ELSE for 1st IF statement
'message if 1st IF statement is false
'end of 1st IF statement
'label to be used for a loop
'loop until both inputs are not active
'return to #test without restoring trippoints
command must occur after an
ELSE
command evaluates false, the controller will skip
IF
command evaluates true, the controller will
IF
DESCRIPTION
ELSE
ENDIF
or
IF
command
DMC-21x5 User Manual 1.0a1

Advertisement

Table of Contents
loading

Table of Contents