WAIT statements (either WAIT SEC or WAIT FOR) do break the advance run, I neglected to mention that. WAIT FOR TRUE is in fact a standard KRL programming trick to deliberately break the advance run without introducing extra time delays. WAIT SEC 0 is another equivalent.
The bottom line, though, is that a WAIT FOR statement, or other commands, is evaluated or executed when the advance pointer gets to it. Just
when that is depends on the setting of $ADVANCE,
and the approximation radii of the motion points. So for the following code:
$ADVANCE = 1 ; set advance to one motion block ahead of main run
PTP P0
PTP P1 C_PTP
CONTINUE
WAIT FOR BooleanVariable1
PTP P2 C_PTP
CONTINUE
WAIT FOR BooleanVariable2
PTP P3 C_PTP
CONTINUE
WAIT FOR BooleanVariable3
The robot should move smoothly through P1,
if BooleanVariable1 is true
before the robot physically reaches the approximation radius around P1. The reason for this is that the approximation radius is the position where the path planner has to decide if it is going to follow an approximated path past P1, or if it will need to move physically to P1 and stop to re-evaluate the WAIT FOR.
OTOH, if $ADVANCE is set to 2, then the robot will only approximate through P2 if BooleanVariable2 is true before the robot physically reaches the approximation radius of
P1. That's because, with $ADVANCE=2, the path planner looks ahead
two motion blocks. This means that when the robot physically reaches the approximation radius of P1, it has to plan out the motions to P2
andP3, which includes checking both BV1 and BV2 right then.
The CONTINUE command is what allows the following command (and ONLY that command) to
not break the advance run. However, since using it this way can be risky -- in the example above, if $ADVANCE is set to 2, that means that BV2 is checked before the robot reaches P1. If BV2 is true at that point, then BV2 is
not checked again -- if BV2 were to become False for some reason while the robot is travelling from P1 to P2, the robot will
not stop at P2 but just keep going.
The same effect applies to output commands, with potentially disastrous results (I learned that the HARD way, years ago).
One approach that can help with this is to use subroutines called by TRIGGER commands. The TRIGGER command allows you to control precisely when/where the subroutine is called, and then you can have as many WAIT and CONTINUE statements inside the subroutine as necessary without creating advance-run issues for yourself.