LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you specifiy the Default value for undefined array elements

Solved!
Go to solution

According to the LV help, arrays have two defaults, the normal default and the default for undefined array elements.  

I presume there must be a way to specify the later default but I cannot find it anywhere.  Any ideas?

0 Kudos
Message 1 of 7
(4,188 Views)

Hmmm, I don't like their choice of wordings.

 

I would call it uninitialized, not undefined.

 

Unless of course an empty array container is considerd "undefined"

 

initA.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 7
(4,179 Views)
Solution
Accepted by topic author viScience

I know you can drag the element out of the array container.  Change the default on that scalar element.  Then drag the element back into the array container.

Message 3 of 7
(4,177 Views)

Thanks!  I tried setting the default in place, making a typedef, etc but did not think to drag it out and back in again.

0 Kudos
Message 4 of 7
(4,154 Views)

In case it's not clear - the value for uninitialized elements is an edit-time only thing and really only makes a difference in what value is filled in if you, say, modify element 6 without previously definining elements 0-5. If you index an undefined element in your code, you'll still get the default value for the datatype (ie, 0 for a numeric) regardless of what you set the uninitialized element value to be.

Message 5 of 7
(4,150 Views)

... and to make things much easier in the future, please vote for this idea. 😄

0 Kudos
Message 6 of 7
(4,148 Views)

@nathand wrote:

If you index an undefined element in your code, you'll still get the default value for the datatype (ie, 0 for a numeric) regardless of what you set the uninitialized element value to be.


That's what this idea was trying to address. 😉

0 Kudos
Message 7 of 7
(4,143 Views)