LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Function "Insert into Array" does not add dynamically generated arrays in a loop

Some people just do not want to hear the truth.
Remeber, they called Gandalf "Stormcrow" but he ended up saving their _____ in the long run.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 18
(2,062 Views)
Using the index is possibly a solution but replacing the function, like Rob did, is easier for me. Lazy as I am I prefer to just replace rather then testing the index version 🙂

But thank you very much for your help! Now I know better how "Insert into Array" works, as the helptext is a bit irritating (I am using the german version). Although I am still confused why my example is working without an error message and if the behaviour is intended by VI.
0 Kudos
Message 14 of 18
(1,867 Views)
I have also seen this, and unless you are able to redesign your code, a quick fix, which I recently found in a Gary Johnson Labview book, is to take the same array, and delete the elements, and then re-use the same array (memory loctions). See attached and see if it helps. I'm not sure which LV version you're using, thus the jpg.
Good luck with it, Doug
Message 5 of 18
(2,062 Views)
The changes do work for my example, but the VI I use is a bit more complicated. I don't know how many elements are in the array, it changes all the time. I know I can test the number of the elements, but testing/deleting/replacing slows down the VI. Using the other function, "Build Array", like Rob suggested, is the best solution for my specific VI.

Thank you for your help!

Arne
0 Kudos
Message 15 of 18
(1,867 Views)
Hi Arne,

I am sort of lost on what it is that is not working. I played with your VI and everything operated the way I expected.

The only thing I can think of is that you are not using a shift register to preserve the results from iteration to iteration.

I have attached two VIs.

The first just varies the dynamic array so we can see it changes with each iteration.

The second uses shift registers to preserve the work from each iteration.

Is this getting close to helping?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Download All
Message 8 of 18
(2,062 Views)
Your first VI is the perfect solution.
It's nearly the same as Rob did and it's the easiest way to fix my problems.

Thank you very much!
0 Kudos
Message 16 of 18
(1,867 Views)
I just ran your attachment in both 6i and 6.1.
This is a bug in LV6i. The VI works correctly (i.e, as you would expect) in the new LV6.1.
0 Kudos
Message 17 of 18
(1,867 Views)
I too have sinned. I was trying to insert a 5x1000 (or is it 1000x5?) into a 0x0. I have seen the err in my ways and will repent by condensing code into smaller vi's.
0 Kudos
Message 18 of 18
(2,052 Views)