From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to edit array elements (without making copies of the array)?

Solved!
Go to solution

Hello all

 

I am new to Labview so I apologise for the newbie question.

 

I am using Labview to check off parts in an assembly as a precursor to a test. For my "checklist" I create an array of clusters, with the cluster containing a string for the part number and a boolean to show if it has been scanned. I read in my parts list and then I would like to add in the part name to each cluster in the array. I do not want to make multiple copies of the array if possible. The code shown below does not work - I previously had the "Array" (my checklist) on the outside of the while loop, as I assumed the inplace elements box would not need an output. The cluster created in the inplace elements is correct, but the "Array" does not change.

 

 

 

InPlace elements.png

 

Any help woud be appreciated, I would prefer a simpler solution to the inplace elements if possible (again without making multiple copies).

 

Regards

 

Ray

0 Kudos
Message 1 of 7
(2,337 Views)
Solution
Accepted by topic author Radiator

You don't show the rest of the code, but I'm guessing that your "Array" is never actually initialized with any values. Thus, the "replace" cannot work since you cannot replace an element that doesn't exist. If the case you are showing is intended to be the actual initialization of the array (and based on what you are saying it seems as if that's the case), then ditch the inplace element structure. All you need to do is to autoindex from your string array and just do this:

 

Message 2 of 7
(2,331 Views)
You are re-reading the initial array every iteration, I bet if you look closely only the last element will have changed. Just replace the tunnel with a shift register.
0 Kudos
Message 3 of 7
(2,320 Views)

That still won't work if the incoming array is empty. Smiley Wink

 

I had also considered the shift register, and should have mentioned it, but the post is somewhat confusing in that it implies the case we are looking at is where the array is supposed to be created. If the array is actually being initialized with "dummy" values someplace else, then, yes, a shift register would do the trick. But if it's not, then nothing would "change". Basically, does the OP mean "initialized" by the word "change", or "alteration of initial values".

0 Kudos
Message 4 of 7
(2,311 Views)
The guessing games could go on for a awhile, but I read the statement "I read in my parts list" to be initializing the array. With that assumption the "array doesn't change" behavior follows from re-reading the initial value. I'll see if the OP clarifies.
0 Kudos
Message 5 of 7
(2,304 Views)
Changing from iPhone to iPad I see that both problems are in there. The IPES will not add elements to an array so an empty array remains empty, and using the tunnel as the input to the IPES will recycle the initial value. Unless you know why you are using the IPES, I would not do it. The shift register is quite efficient at handling memory issues so I would wait for an actual problem instead of anticipating one in this case.
0 Kudos
Message 6 of 7
(2,300 Views)

Thanks for the prompt replies. 

 

I had not initialised the array correctly and using the code above sorted it out.

 

Thanks

0 Kudos
Message 7 of 7
(2,268 Views)