LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to concatenate 2 arrays to feed into for loop?

In the attatched files, i want to run some test suites and use 'Group Array' and 'Test Array' as inputs from various tests. The other fields are always the same and have hardcoded them. Right now, i wired the hardcoded arrays as both name and value as i cant seem to find the proper block to input into the for loops. The output XML looks exactly as i want it, the only problem is the values i cant get working. Programatically, i would make an array of key-value pairs and iterate through that.

 

Thanks!

 

 

Download All
Message 1 of 12
(3,499 Views)

I'm not exactly sure I've understood what you want, but would the following kind of thing work?

 

Caller/Test VI (populate map and pass in)Caller/Test VI (populate map and pass in)

 

Pass the Map into a For loop and autoindexPass the Map into a For loop and autoindex

 

Here you can write a test (like the caller) that calls Insert into Map appropriately for each of the Keys you're interested in, and then get the values from the VI you're testing?

Then your subVI here can iterate through the Map and insert the XML attributes.

 

 

 

 


GCentral
0 Kudos
Message 2 of 12
(3,466 Views)

(On a side note, all three of your recent topics deal with basically the same thing. It would help to keep it all in one place)

Message 3 of 12
(3,450 Views)

Understood, will keep further discussions on this post.

 

How can i build a map from two 1D arrays? If i input the 2 arrays into a for with indexing enabled and use the build map function, it only lets me output with 'Last Value' enabled. I need to build these kind of maps with values from other blocks where the 'ITEMS' array is (almost) always the same but the 'VALUES' array varies accordingly with the tests i run. 

 

Basically i need to input 2 arrays and output a map such that i can pull values by key in a different block.

0 Kudos
Message 4 of 12
(3,420 Views)

Replace your tunnel with a Shift Register and wire an empty map onto the input side (it can be easier to create a constant after wiring the inside edges of the loop).

 

You want to call insert into map inside the loop in the situation you're describing, the output is a single Map, not an array so no need for indexing tunnels on the output.


GCentral
0 Kudos
Message 5 of 12
(3,410 Views)

Here's an example that I think shows what you're describing:

cbutcher_0-1614185361899.png

 

Then wire the map wherever you need it.

Of course, if you have two arrays like this, you could also use an array of clusters of Name/Value strings or a 2D array, if you don't need to search the data for a specific key in different orders than you insert them or similar...

 


GCentral
Message 6 of 12
(3,402 Views)

@AndreiV wrote:

How can i build a map from two 1D arrays? If i input the 2 arrays into a for with indexing enabled and use the build map function, it only lets me output with 'Last Value' enabled. I need to build these kind of maps with values from other blocks where the 'ITEMS' array is (almost) always the same but the 'VALUES' array varies accordingly with the tests i run. 

 

Basically i need to input 2 arrays and output a map such that i can pull values by key in a different block.


Don't just randomly place primitives on the diagram! Most function have a help page as well as examples. Just place one of the map function on the diagram  and do a "right-click...help" or "right-click...examples" and it will tell you exactly how to use it!

 

Critical beginner topics you need to learn are the various flavors of loop tunnels (plain, indexing, conditional, etc.) and the shift register. They occur in almost all programs.

 

In this particular case, here's the simplest way:

 

altenbach_0-1614185791664.png

 

 

(If you want to learn more about sets and maps, have a look at my presentation from a few years ago. Enjoy!)

 

Message 7 of 12
(3,395 Views)

Thanks everyone for the answers!

 

Is there a way to enlarge the pin Window? I have found a way to make a pop-up window that tells you which pins are connected, but what about the case when i want to add a new pin? Its very small and it takes multiple tries to select the pin when there's a lot of them.

 

Have attached a photo of said window.

0 Kudos
Message 8 of 12
(3,351 Views)

Hi Andrei,

 


@AndreiV wrote:

Is there a way to enlarge the pin Window? I have found a way to make a pop-up window that tells you which pins are connected, but what about the case when i want to add a new pin? Its very small and it takes multiple tries to select the pin when there's a lot of them.


When you use a connector pane (abbreviated as conpane, remember to use official LabVIEW terms) with so many terminals and you still ask for more terminals then you do something completely wrong! The common recommendation is to use the 4-2-2-4 pattern…

To answer your question: No, there is no way to enlarge the connector pane.

 

Would you write functions in text-based programming with 20+ inputs/outputs? Would you consider that as "good practice"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 12
(3,348 Views)

I understand it's bad practice as but the schematic isn't mine. In case i have improperly worded my question: i dont want to add any extra pins, i just want to see if i can make the connection panel larger in size to be easier to click.

 

I cannot change the current number of inputs/outputs as they're part of a way larger project.

0 Kudos
Message 10 of 12
(3,338 Views)