08-07-2024 11:58 AM
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?
Solved! Go to Solution.
08-07-2024 12:12 PM - edited 08-07-2024 12:22 PM
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!)
08-07-2024 12:13 PM
There is a property for the array for the number of visible elements. You could just hide any uninitialized elements.
08-07-2024 12:24 PM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-07-2024 12:37 PM
@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. 😄
08-07-2024 12:42 PM
@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.
08-07-2024 12:46 PM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-07-2024 12:52 PM
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.
08-07-2024 12:54 PM
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.
08-07-2024 12:57 PM
@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.