Topic: DMD0080

Help File Version: 2.9.4.37

NEXT - Index by Step


The Index by Step (NEXT) instruction marks the end of a For / Next loop.

 

 

This instruction is a 'power-rail' instruction, meaning that it is displayed in the left-most column of the ladder diagram (the power rail). Creating new instances of this instructions is a bit counter-intuitive because they cannot be entered directly on the power rail in the Ladder Editor. The first step is to position the edit cursor in the output column (the far right) of the rung in the ladder logic diagram instead of positioning it against the power rail (the far left). At that point you can enter the instruction's mnemonic or double click on the instruction's name in the Instruction Toolbox. You can also drag / drop the instruction from the Toolbox anywhere on the rung and it will be created in the power rail of that rung.

 


Parameters:

There are no parameters for this instruction.

 


Status Display:

 

The NEXT instruction will show the current .TimeSlice value of the Program or Task when status is ON.

 

The  blue  triangle in the upper left corner indicates this is a Yielding 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

 


Rung 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.