Reference Manual
PMAC 2 Software Reference 
PMAC Program Command Specification  357 
For example, if the condition only needs to be checked every 20 msec and not every Real 
Time Interrupt, you should consider using a DWELL command to regulate the execution 
time of the WHILE loop. 
WHILE ({condition}) 
 DWELL20 
ENDW
Example 
WHILE (M11=0) WAIT    ; Pause here until Machine Input 1 set 
WHILE (M187=0) WAIT    ; Pause here until all axes in-position 
M1=1          ; Turn on Output 1 to activate punch 
See Also 
I-variable Ix28 
Program commands DWELL, DELAY, STOP 
WHILE({condition}) 
Function 
Conditional looping 
Type 
Motion program (PROG only); PLC program 
Syntax 
WHILE ({condition}) 
WHILE ({condition}) {action} 
where: 
•  {condition} consists of one or more sets of {expression} {comparator} 
{expression}, joined by logical operators AND or OR. 
•  {action} is a program command. 
Remarks 
This statement allows repeated execution of a statement or series of statements as long as 
the condition is true. It is PMAC’s only looping construct. It can take two forms: 
1.  (Valid in motion program only) With a statement following on the same line, it will 
repeatedly execute that statement as long as the condition is true. No ENDWHILE is 
used to terminate the loop. 
WHILE ({condition}) {action} 
2.  (Valid in motion and PLC programs) With no statement following on the same line, 
it will execute statements on subsequent lines down to the next ENDWHILE 
statement. 
WHILE ({condition}) 
 {statement} 
 [{statement} 
 ...] 
 ENDWHILE 
If a WHILE loop in a motion program has no move, DWELL, or DELAY inside, PMAC 
will attempt to execute the loop twice (while true) each real-time interrupt cycle (stopped 
from more loops only by the “double-jump-back” rule), much like a PLC0. This can 
starve the background tasks for time, possibly even tripping the watchdog timer. PMAC 
will not attempt to blend moves through such an “empty” WHILE loop if it finds the loop 
condition true twice or more. 
In PLC programs, extended compound WHILE conditions can be formed on multiple 
program lines through use of AND and OR commands on the program lines immediately 
following the WHILE command itself (this structure is not available in motion programs). 
Conditions in each program line can be either simple or compound. AND and OR 
operations within a program line take precedence over AND and OR operations between 
lines. 










