Topic: DMD0077

Help File Version: 2.9.4.37

BREAK - Exit Loop


The Exit Loop (BREAK) instruction will immediately break out of the enclosing For / Next, While / Wend, or Repeat / Until loop. This instruction will cause the program to skip over all of the ladder logic instructions between BREAK instruction and the NEXT, WEND, or UNTIL instruction that ends the loop and no more iterations of the loop will be processed.

 

 

Program execution will continue with the instruction immediately following the NEXT, WEND, or UNTIL instruction that marks the end of the loop.

Parameters:

This instruction has no parameters.

 


Status Display:

 

The green triangle in the upper left corner indicates this is a Skipping instruction.

 


See Also:

BREAK - Exit Loop

 

CONTINUE - Skip to Loop End


FOR - Index Loop

 

NEXT - Index By Step


REPEAT - Loop Until Condition is Non-Zero

UNTIL - Repeat Until Condition is Non-Zero


WEND - While End

 

WHILE - Loop While Condition is Non-Zero

 


Example:

The following simple example uses V100 as the loop index. It will be initialized to 4000 (From) on the first pass through the loop, and will increment by 1 (By Step) on each successive pass until it gets to 4009 (To).

 

Each pass through the loop the comparison contact will compare the value in D[V100] - which is D4000, D4001, D4002 ... D4009 - to the value in D4010. If the value in D[V100] is greater than the current value in D4010, the value in D[V100] will be copied to D4010.

 

If a negative value is found the loop processing is stopped with the Break instruction.