Reference Manual
PMAC 2 Software Reference
PMAC Program Command Specification 315
See Also
I-variable I5
On-line commands ENABLE PLC, DISABLE PLC, ENABLE PLCC, DISABLE
PLCC, <CONTROL-D>
Program command ENABLE PLC, DISABLE PLC, DISABLE PLCC
ENDIF
Function
Mark End of Conditional Block
Type
Motion program (PROG only), PLC program
Syntax
ENDIF
ENDI
Remarks
This statement marks the end of a conditional block of statements begun by an IF
statement. It can close out the “true” branch, following the IF statement, in which case
there is no false branch, or it can close out the “false” branch, following the ELSE
statement.
When nesting conditions, it is important to match this ENDIF with the proper IF or
ELSE statement. In a PLC program, every IF or IF/ELSE pair must take an ENDIF,
so the ENDIF always matches the most recent IF statement that does not already have a
matching ENDIF. In a motion program an IF or ELSE statement with action on the
same line does not require an ENDIF, so the ENDIF would be matched with a previous
IF statement.
Example
IF (P1>0)
X1000
ENDIF
IF (P5=7)
X1000
ELSE
X2000
ENDIF
See Also
Logical Structures (Writing a Motion Program)
Conditional Statements (Writing a PLC Program)
Program commands IF, ELSE
ENDWHILE
Function
Mark End of Conditional Loop
Type
Motion program (PROG only), PLC program
Syntax
ENDWHILE
ENDW
Remarks
This statement marks the end of a conditional loop of statements begun by a WHILE
statement. WHILE loops can be nested, so an ENDWHILE statement matches the most
recent WHILE statement not already matched by a previous ENDWHILE statement.
In a motion program a WHILE statement with an action on the same line does not require
a matching ENDWHILE.
In the execution of a PLC program, when an ENDWHILE statement is encountered, that
scan of the PLC is ended, and PMAC goes onto other tasks (communications, other