12-21-2021 06:47 AM
I have an array of cluster of cluster borrowed from the "FGEN Arb Script.vi" example. By default, this is a 1D array with length 4 which allows the example to rotate through 4 output waveforms. For my application, I would like to have an adjustable number of waveforms. But I cannot find a simple way to change the length of the array control, either programmatically or before Run.
I have tried:
+ Examining the size property via right click. I can change the number of dimensions, but not the length (see attachment) which seems strange. The Array Size node returns the expected value (4).
+ NumRows and NumCols property nodes. These seem to adjust the number of array elements visible on the front panel, but not the length of the underlaying array.
+ Initializing a new array of clusters with the desired length then backforming a control. This does create an array of clusters with the new length, but it is unacceptably clunky as it requires rewiring on the block diagram every time. And heaven forbid I have to explain this procedure to a labmate!
Is there a simple way to change the length of this array control? If there is a loop-able programmatic solution to make this a user controllable parameter, so much the better.
Solved! Go to Solution.
12-21-2021 08:18 AM - edited 12-21-2021 08:19 AM
Hi octopod,
@octopod wrote:Is there a simple way to change the length of this array control?
Simplest way: Use the context menu of the array (aka right-click the array!), then see the "Data operations" submenu to insert/delete elements to the array…
12-21-2021 10:33 AM
This has nothing to do with the number of elements in the array, it's for setting the number of dimensions.
If you want to set elements in a control, you can use a local or a value property.
LabVIEW Programming ((make LV more popular, read this)
12-21-2021 11:21 AM - edited 12-21-2021 11:25 AM
Here's a quick example that constantly changes the value and size of an array control at runtime.
Of course in a real application, you need to make sure not to interfere with the user actions on the same array control, so make sure that there is only one master in any given state of the run.
12-21-2021 12:57 PM
Please do read through the training material. You seem to be missing a basic concept of LabVIEW that the wire is the data, not the control or indicator. To change the amount of data that's in the array you have to actually change the amount of data that goes into the wire.
12-21-2021 06:01 PM
12-22-2021 04:05 AM - edited 12-22-2021 04:15 AM
@altenbach
Thank you for this detailed answer. I am undoubtedly missing some LabVIEW skills as it did not even occur to me to create a local variable, which seems like the most straightforward solution. I'll take a look at some of the relevant tutorials.
12-22-2021 04:11 AM - edited 12-22-2021 04:56 AM
@GerdW
Thank you for this. I don't see this option in when I look at the array's "Data Operations" submenu (see attachment) from the front panel or block diagram. But it is visible in the "Data Operation" submenu for a single element of the array (accessible from the front panel). In my mind, length is a property of the array, not of any particular element, so I failed to fully investigate the elements' context menu. Thanks for pointing me in the right direction.
12-22-2021 04:35 AM
@octopod wrote:
@GerdW wrote:
Hi octopod,
@octopod wrote:Is there a simple way to change the length of this array control?
Simplest way: Use the context menu of the array (aka right-click the array!), then see the "Data operations" submenu to insert/delete elements to the array…
I don't see that option in the "data operations" submenu.
You're clicking in the terminal.
You get this option with the control\indicator on your front panel, or with an array constant.
A few things though:
1) You're changing the value. You'd have to make this value default, or it won't be saved.
2) The value is possibly changed by the code. Adding a value on the front panel will simply be changed by your code.
LabVIEW Programming ((make LV more popular, read this)
12-22-2021 04:44 AM
Thanks! I'll admit I'm confused that we measure the length of an array with the "Array Size" node, but can't view or edit the length from the "Size" properties tab. Is 'size' length or is it dimensions?