Reference Manual

PMAC 2 Software Reference
PMAC Program Command Specification 313
condition.
ELSE lines can take two forms (only the first of which is valid in a PLC program):
With no statement following on that line, all subsequent statements down to the next
ENDIF statement will be executed provided that the preceding IF condition is false.
ELSE
{statement}
[{statement}
...]
ENDIF
With a statement or statements following on that line, the single statement will be
executed provided that the preceding IF condition is false. No ENDIF statement should
be used in this case.
ELSE {statement} [{statement}...]
Note:
This single-line ELSE branch form is valid only in motion programs. If
this is tried in a PLC program, PMAC will put the statements on the next
program line and expect an ENDIF to close the branch. The logic will
not be as expected.
Example
This first example has multi-line true and false branches. It could be used in either a motion
program or a PLC program:
IF (M11=1)
P1=17
P2=13
ELSE
P1=13
P2=17
ENDIF
This second example has a multi-line true branch, and a single-line false branch. This structure
could only be used in a motion program:
IF (M11=0)
X(P1)
DWELL 1000
ELSE DWELL 500
This example has a single-line true branch, and a multi-line false branch. This structure could
only be used in a motion program:
IF (SIN(P1)>0.5) Y(1000*SIN(P1))
ELSE
P1=P1+5
Y(1100*SIN(P1))
ENDIF
This example has single-line true and false branches. This structure could only be used in a
motion program:
IF (P1 !< 5) X10
ELSE X-10
See Also
Program commands IF, ENDIF.