LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create multi-dimensional arrays of controls?

Solved!
Go to solution

I'm building a VI that will have hundreds of on/off buttons, 24 on each of 8 tabs.  I can deal with them programmatically in an array, like this:

 

 

array of buttons.PNG

 

and then find which one was pushed with some XOR'ing:

 

array of buttons event str.PNG

 

But what if I want two rows of 12 buttons?  Can I make a 2D array of buttons somehow?  Or a 1D array of buttons on two rows for cosmetic reasons?

 

What if I want to put 24 buttons on each of 8 tabs?  Can I make a 24x8 array of controls somehow?  Or a 12x2x8?

 

Thanks,

-Jordan

0 Kudos
Message 1 of 14
(4,459 Views)
Solution
Accepted by topic author jordanglassman

Right Click on the Index Display and Add Dimension.

 

I'd be wary of putting too many buttons though. Makes for a clunky interface.

0 Kudos
Message 2 of 14
(4,452 Views)

That was easy; here is the two dimensional array:

 

2d array of buttons.PNG

 

I can add the third dimesion using this technique, but how do I get access to the third dimension on the front panel, graphically, to make a 12x2x8 array of buttons?

 

I agree there are a lot of buttons, but it seems like the easiest way to quickly toggle channels on and off, much quicker than a drop down menu or some other interface.  What would you recommend?

 

Thanks,

-Jordan

 

 

0 Kudos
Message 3 of 14
(4,442 Views)

Anything's possible. Right click on your control and add a dimension if you wish to make it a 2x12 array. You can add a third dimension to an array (page), but it's not particularly useful for front panel controls.

 

You could consider having a 2nx12 array with labels next to each block of 2n arrays. Or, and I think this is the most expandable myself, an array of clusters of 2x12 arrays:

 

clustersnip.PNG

 

You can tidy up the appearance as you wish, and of course you'll have to deal with the logic of what's been updated (a quick search through here will show you how to check which element of a cluster has changed, for instance).

---
CLA
Message 4 of 14
(4,438 Views)

@jordanglassman wrote:

 

I agree there are a lot of buttons, but it seems like the easiest way to quickly toggle channels on and off, much quicker than a drop down menu or some other interface.  What would you recommend?

 

Thanks,

-Jordan

 

 


Depends on what the actual purpose of the interface is.
Will you actually need access to all channels all at once?

Normally, I'd start with some sort of a ListBox or Tree to narrow down the information to only what's relevant.

 

With so many buttons, I think the risk of a misclick is pretty high.

0 Kudos
Message 5 of 14
(4,420 Views)

Let's consider a tab control scenario with an array of 24 buttons on each tab, with 8 tabs.

 

If I understand you correctly, I will need to use a separate 2D array of buttons for each tab. It's not possible to have a 12x2x8 array of buttons?  I will need to monitor all 8 arrays separately for events?

 

Thanks!

0 Kudos
Message 6 of 14
(4,378 Views)

Hi jordan,

 

what's the point to monitor those 8 arrays with an event structure?

You can use just one event case to monitor all 8 arrays!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 14
(4,374 Views)

Aha!  I didn't know you could assign multiple events to one case.  This allows me to emulate a "3D" array of controls.  Thanks!

0 Kudos
Message 8 of 14
(4,369 Views)

jordanglassman wrote:

I can add the third dimesion using this technique, but how do I get access to the third dimension on the front panel, graphically, to make a 12x2x8 array of buttons?


I would probably use a 3D array directly. You can easily hide the index terminal (and scrollbars) and add a custom numeric control to select the visible plane via an event structure.

Make sure to make the full sized 3D array the default or initialize it at program start.

0 Kudos
Message 9 of 14
(4,348 Views)

@jordanglassman wrote:

 

and then find which one was pushed with some XOR'ing:

 

array of buttons event str.PNG


I would strongly recommend to replace the XOR with a not equal. Same outcome, but less nerdy. 😄 It is also much more universal! For example if you ever need to do this on an array of numerics to see which element got changed (I often do!), the XOR will no longer work as well (with integers, you'll end up with bitwise comparisons and numeric results, and with DBLs you'll end up with coercions and unpredictable results because bits are lost).

0 Kudos
Message 10 of 14
(4,335 Views)