Galil DMC-2X00 Projector User Manual


 
90 Chapter 7 Application Programming DMC-2X00
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 as its arguments 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 controller 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.
It is recommended that the user not include jump commands inside IF conditional statements since this
causes redirection of command execution. In this case, the command interpreter may not execute an
ENDIF command.
Using the ELSE Command
The ELSE command is an optional part of an IF conditional statement and allows for the execution of
command 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 controller will skip commands until the ELSE command. If the argument for the IF command
evaluates true, the controller will execute the commands between the IF and ELSE command.
Nesting IF Conditional Statements
The DMC-2x00 allows for IF conditional statements to be included within other IF conditional
statements. This technique is known as 'nesting' and the DMC-2x00 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
Format: description
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.
Instruction Interpretation
#TEST Begin Main Program "TEST"
II,,3 Enable interrupts on input 1 and input 2
MG "WAITING FOR INPUT 1, INPUT 2" Output message
#LOOP Label to be used for endless loop
JP #LOOP Endless loop
EN End of main program
#ININT Input Interrupt Subroutine
IF (@IN[1]=0) IF conditional statement based on input 1
IF (@IN[2]=0) 2
nd
IF executed if 1
st
IF conditional true
MG "INPUT 1 AND INPUT 2 ARE ACTIVE" Message executed if 2
nd
IF is true