LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem: array always reinitialize

Hi,
I want to add elements to an array in a for loop.  Outside the for loop, I initialize the array and pass this array to the for loop. 
Now, everytime I insert a new element in the array in the for loop, the array is reinitialized.
How can I do that?
0 Kudos
Message 1 of 13
(3,764 Views)
Your question is a bit unclear.  Can you post your code so that we can better see what you are trying now.
Jim

LV 2020
0 Kudos
Message 2 of 13
(3,758 Views)

The easiest and most efficient method is wire the element out of the loop. It will automatically build an array (unless you right click the tunnel and disable the auto indexing). Alternatively, you could use a shift register - this will make sure you have the same data in the wire between iterations, but building arrays inside loops is inefficient when it comes to memory management. Just use the auto indexing.

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.


___________________
Try to take over the world!
0 Kudos
Message 3 of 13
(3,755 Views)

OK,

I want to add some elements in an array and fill it in inside a for loop.  But because I initialize this array outside the loop, every time I add an element to the array inside the for loop, the array is reinitialized.

How can I feel in an array in a for loop, just like you would do in a C code?!

0 Kudos
Message 4 of 13
(3,750 Views)
I don't understand what you're talking about when you say : wire the element out of the loop????
 
I'm sure you tried once to add some elements to an array in a loop?!
0 Kudos
Message 5 of 13
(3,744 Views)
Are you talking about doing something like this? 

oops! posted the wrong pic the first timeSmiley Surprised


Message Edited by lmtis on 07-31-2008 12:56 PM
Jim

LV 2020
0 Kudos
Message 6 of 13
(3,737 Views)
If I could just take an array and insert some elements into it, but I have to initialize it and it always does, I don't understand that!!!
0 Kudos
Message 7 of 13
(3,728 Views)
You cannot insert elements into an empty array unless you're inserting at index 0. You either have to use Build Array (as has already been suggested) or you have to start with a pre-populated array.

To reiterate:

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
0 Kudos
Message 8 of 13
(3,718 Views)
Imtis, it's exactly what I want to do, but it doesn't keep all the value I puted in the array...that's the problem.
0 Kudos
Message 9 of 13
(3,708 Views)
Please post your code.
0 Kudos
Message 10 of 13
(3,705 Views)