Search code examples
labview

The operation of a For Loop iterating over an empty array in LabVIEW


enter image description here

I want to ask that why is the Value Out 5 not 4?

In my thinking, "i" value will be 0 at first, then plus 1 and be subtracted by 5, it should become (5-1), that is 4. But the answer is 5. Why?


Solution

  • You wired an empty array to your For loop. When you wire an array to an indexing input terminal of a For loop, LabVIEW automatically takes the length of the array as the iteration number for the loop. It means your For loop doesn't execute any iterations (iteration number = 0).

    You wired a value of 5 into the left-hand terminal of your shift register. So, when you push the run button, 5 will be written into the shift register.

    Finally, your indicator will read the data in the shift register. Since your For loop doesn't do any work, the value 5 will remain in the register and your indicator will display the value 5.