LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster Array Uninitialized Elements

Solved!
Go to solution

I have an array of clusters on my front panel that can show uninitialized elements of the array. The cluster contains a string that for the uninitialized elements is always displaying the value from the most recently modified element. I've included a screenshot for reference. The cluster used is a strict type def. I would like to avoid having to initialize more array elements than I am actually using for example with an empty string to resolve the issue. Does anyone have any ideas on how to make sure those elements remain blank until modified?

 

nsarrault_0-1723049176375.png

 

0 Kudos
Message 1 of 17
(1,121 Views)

We need to see some simplified code. What is the default value for the string array element?

 

(Elements outside the valid range will show whatever the default value is, so fix that!)

0 Kudos
Message 2 of 17
(1,114 Views)

There is a property for the array for the number of visible elements.  You could just hide any uninitialized elements.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 17
(1,112 Views)

@crossrulz wrote:

There is a property for the array for the number of visible elements.  You could just hide any uninitialized elements.


This is what I do.  You can even get fancy and have a scrollbar shown or not shown based on how many items the current UI can display at once.  I may have gone further a few times and made a custom scrollbar that also only shows that number of items, and not allow going past the number of elements like the default scrollbar on an array will.

0 Kudos
Message 4 of 17
(1,100 Views)

@crossrulz wrote:

There is a property for the array for the number of visible elements.  You could just hide any uninitialized elements.


It also depends if this is a control or indicator. If it is a control, we need to be able to add elements, which is not a problem for indicators.

If it is an indicator, you also need to decide what to show if the array is empty (e.g. hide the entire indicator).

 

To solve the stated problem, all they need is change the default value for the string element. Everything else is outside that scope of the question for now. 😄

0 Kudos
Message 5 of 17
(1,091 Views)

@altenbach wrote:
It also depends if this is a control or indicator. If it is a control, we need to be able to add elements, which is not a problem for indicators.

It's not a problem for controls either.  It is simple enough to have an "Add Item" button that triggers an Event Structure to add the default value to the end of the array and make it visible.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 17
(1,083 Views)

@crossrulz wrote:

@altenbach wrote:
It also depends if this is a control or indicator. If it is a control, we need to be able to add elements, which is not a problem for indicators.

It's not a problem for controls either.  It is simple enough to have an "Add Item" button that triggers an Event Structure to add the default value to the end of the array and make it visible.


Yup, and possibly a right click menu for add or remove items.  You can also have a cluster be a control, but disable individual elements.  This makes the cluster editable but only on some elements.

0 Kudos
Message 7 of 17
(1,077 Views)

The default value of the string element is an empty string as defined in the type def. When the array originally initializes it is blank and it is only when the program begins to modify the array by adding elements does the value in the uninitialized strings change.

 

It is technically a control but is being used primarily as an indicator. The string and picture rings are both disabled in the type def so they don't allow user input and are written programmatically. It is defined as a control to make the button on the right usable.

 

I am going to try and use the visible rows method and see if that will work well.

0 Kudos
Message 8 of 17
(1,068 Views)

Yes, more code. No problem. 😄

 

The main problem is that they state that the invalid element seem to show different values ("... always displaying the value from the most recently modified element"), which is very had to explain. That should not be possible! They should always display the default value.

 

That's why I was asking for the code in my first answer. Let's focus on that.

0 Kudos
Message 9 of 17
(1,067 Views)

@nsarrault wrote:

The default value of the string element is an empty string as defined in the type def..


Can you attach the type def? Not that you can change the default value of the placed typedef, so it is not necessarily whatever the typedef has. A typedef does not define values, just datatypes.

0 Kudos
Message 10 of 17
(1,061 Views)