User | Kudos |
---|---|
8 | |
6 | |
4 | |
3 | |
2 |
Array elements can have a default value that is different from the default for the datatype. This is useful!
However, the use is not consistent across LabVIEW, here is a simple example:
(1) If we index into an array, and the index falls outside the current range, we get the default for the datatype ("" in this case), and not the default for the array element (which is not an empty string here!).
(2) However, if we add a new element skipping a few elements, the elements in between get the default value for the array element, and not for the datatype.
This seems inconsistent and the help pages actually confuse it even more.
From the help on "Index array"
"If the index is out of range element or subarray returns the default value of the defined data type for the array."
Clicking of the default value link above says that:
The default value is the value used to pad the array when the array expands. For example, if you set the array index to a value beyond the defined portion of the array and enter a value in an element greater than one row past the defined portion of the array, the elements between the previous end of the array and the element you added are set to the default value.
As is obvious from the observations in example (2), the underlined statement seems actually incorrect!
IDEA: I suggest that indexing outside the range of an array should return the default value for the element (if defined).
In the case (1), it should return the 7 character string "Nothing" instead of an empty string.
(of course this change might break a lot of legacy code, not sure what to do about it)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.