LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating elements in Primary Array with elements from secondary array in different location/index

I have two arrays, a primary and secondary array. Each array is composed of cluster elements (name string, numeric value).  The primary array is in the correct order that must not change.  The secondary array contains the updated numeric values for corresponding name string.  However, the elements in the secondary array are not in the same order as the primary. How would I do a swap so that the Primary array now contains the updated values and remains in the same order.

I have created an example VI (LV 8.2) (which I thought would work) that only puts in the first element and then all data stops being passed after that.

This example contains two arrays with cluster elements containing a name string (color) and numberic value (integer).
Primary Array
Red 24
Blue 21
Green 75
Black 4
Yellow 5

The seconday array (updated numeric values but in different order)
Blue 2
Black 77
Yellow 1
Green 444
Red 12

The Final Array (Primary Array updated with new values) should be
Red 12
Blue 2
Green 444
Black 77
Yellow 1

Remember that changing the order of the Primary/Final array is not allowed.


0 Kudos
Message 1 of 5
(2,456 Views)

Just keep it simple! 😄

Attached is one possible solution (assuming that each tag only occurs once in the primary array).

 

Message Edited by altenbach on 09-29-2006 08:13 AM

Download All
Message 2 of 5
(2,445 Views)
Thanks for the help. I actually got my VI to work correctly a few minutes before I read your post.  But you method is much simpler.

I have a lot to learn about programming in Labview. 

I am going to try an implement you VI in my application. Hopefully it works!!
0 Kudos
Message 3 of 5
(2,430 Views)
altenbach

thanks for the solution..applied your method to my application and everything is working great....

without this forum and the expertise of the members in here, i know i would be lost...


0 Kudos
Message 4 of 5
(2,424 Views)
Note that my solution is most general and recommended if there are more than 2 elements in each cluster (including tag string) and you only want to change one cluster element. In your particular case, there is only the tag and a single numeric in the cluster. In this case you can simplify things even more as in the attached picture. 🙂
 
 
 
Note also that my two solutions als automatically work with smaller "new values" arrays in case you only need to change a few elements.
 

Message Edited by altenbach on 09-29-2006 11:47 AM

0 Kudos
Message 5 of 5
(2,419 Views)