In this tutorial, you will learn the concept of auto-indexing using loops in LabView. At the start there is a complete general introduction explaining the working and uses of auto-indexing. After that, auto-indexing is explained with the help of a program on LabView. Enabling and disabling of auto-indexing is done. At the end of the tutorial you are provided with an exercise to do it by yourself, and in the next tutorials I will assume that you have done those exercises and I will not explain the concept regarding them. Introduction to auto indexing in LabviewUsing loops in LabView you may have noticed and whenever you place an outgoing wire through a loop, the tunnel is either solid or have square brackets on them. What do these differences in the tunnels represent?When you have small brackets inside the tunnels, auto-indexing is enabled.
This setting is unique in all versions of LabView using either for loop or while loop. LabView also sets the count terminal to the array if you enable auto-indexing on an array wired to a For Loop input terminal, so you do not need to wire the count terminal.Common application of a ‘For’ loop is basically is to process the individual elements of array. Therefore, auto-indexing is enabled by default for every array you wire to a For Loop. If processing array elements in array individually is not required you can also disable auto-indexing.
‘For’ loop handles all the elements in the array at once if you disable auto-indexing input instead of handling an element per iteration.The output array receives a new element from every iteration of the loop, when you auto-index an array output tunnel. Hence the size and number of iterations of the auto-indexed output array are always equal. Last iteration data will be received if you disable auto-indexing in the output tunnel and not the elements individually.

You can also change this setting by clicking right on the tunnel and select Disable Indexing or Enable Indexing.When working with while loop auto-Indexing is disabled by default, so the wiring tunnel will be solid. The while loop indexes of the array work in the same manner as that of for loop when you enable auto-indexing for an array entering a While Loop. While loop iterates until a specific condition is satisfied, therefore, the number of iterations a While Loop executes is not limited by the size of the array. The output array receives a new element from every iterations when you auto-index an array output tunnel. Auto indexing program in Labview.
As an example, consider a ‘for’ loop that generate random numbers in the output. For this purpose create a blank VI and save it as done in previous tutorials. Place a for loop in it from function palettestructuresfor loop as shown belowFigure 1: for loop. Set the number of iterations to 10, by using a constant. From the function palette select numeric and then select random number this will generate random numbers automatically.Figure 2: Random number block.
Connect the output terminal of the random number generator to the boundary of the ‘for’ loop. It will create a tunnel, see the figure below.Figure 3: Tunnel.
You can see two square brackets inside the tunnel, and when you hover over the tunnel the pointer will say “Auto-indexed tunnel”, refer to the figure below,Figure 4: Auto indexing tunnel. This means that the auto-indexing is enabled. What this means is that the loop will automatically create an array from the scalar values that reach the values inside the loop.
Now by right clicking on this tunnel a dropdown will appear, select create from that menu and then select indicator as shown below.Figure 5: Indicator. This will automatically place an array indicator on the tunnel, this is because of the auto-indexing tunnel.Figure 6: Array indicator. As we have discussed in introduction portion, the size of this array must be equal to the number of iterations.