LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to provide values to an array inside a for loop?

Hi

I have 2 for loops in my block diagram. These for loops are further inside a while loop. The first for loop contain an array of digital controls. I am able to read the value in the array one by one outside the for loop.
Now, i Want to store these values inside an array of digital indicators. This array is inside nother for loop. As long as I don't change the values in the control array, the values in the indicator array should not change. The problem is that with every iteration of the second for loop, the values of the indicator get changed.How do I rectify this problem..
I have attached my program.
0 Kudos
Message 1 of 3
(2,784 Views)
Hello

Your program has some special vis which are not in standard installation. Try to send a simple vi.
I think you could also explain more clearly what you want to do.

regards
Pawel
0 Kudos
Message 2 of 3
(2,777 Views)
Excuse me for saying this but your code has lots of errors. You are using locals unnecessarily. There is no data dependency connection between the two loops so they will both run at the same time, and there is no guarantee which one will execute first. If the second loop runs first, you will be reading a local variable that has not been written to yet. According to your question, with every iteration of the second loop, the indicator will get changed because that is the way you wired it to work. In for loop number one, you have a shift register where none is needed. The shift register is not even completely wired (terminal on left side unwired). If you want to store values from an array into an array of indicators, your vi is all wrong. Delete the shift register and the local variable from for loop 1. Wire the output from index array to the loop edge with indexing enabled. Wire this loop output terminal to the indicator array. Delete everything else outside the for loop 1, and remove the while loop. Now the array that is built inside the for loop will get transfered to the indicator array. See the attached vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 3
(2,767 Views)