01-16-2009 02:38 PM
Ideally, one would know the size of an array one creates but I will be working with existing vi and this seems an important piece of information.
For instance, with auto-indexing on, I am told that the index of a For Loop (for instance) will be based on the "size of the array" rather than the value specified at the N connection.
I can see the size of an array expands as data is added manually. Does that mean the array is sized to the Index value with the first NULL entry?
In that case, would an array be able to hold a Null value (if Null has any meaning in this context)?
Solved! Go to Solution.
01-16-2009 02:46 PM
I do not understand the premise of your question. The index of a for loop has nothing to do with the size of an array. The index is simply which iteration the loop is currently in. The number of times a loop executes is based on whether you have (a) N wired; or (b) are auto-indexing. Auto-indexing simply means that LabVIEW will know how many times to execute the loop based on how many elements are in the array. If you wire two arrays and auto-index both, then the smaller array will dictate how many times the loop executes. If you wire N and auto-index an array, then the smaller of N and the size of the array is used.
I have no idea what you mean by "the first NULL entry".
To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
01-16-2009 02:49 PM - edited 01-16-2009 02:52 PM
There is an "array size" primitive in the array palette. The array size in not related to the number of visible elements on the front panel.
wildcatherder wrote:For instance, with auto-indexing on, I am told that the index of a For Loop (for instance) will be based on the "size of the array" rather than the value specified at the N connection.
This is incorrect. The iteration will be based on the smallest of the following numbers: the size wired to N, the sizes of any aotoindexing array inputs.
So if you wire a zero to N, the loop will not iterate, no matter how big the autoindexing arrays are. In newer LabVIEW versions, the FOR loop cal also terminate early (if you enable the conditional terminal).
01-16-2009 03:48 PM
I am going through tutorials. That is how I am encountering these questions.
LabVIEW for Everyone 3rd. pg. 251 "LabView sets the count to the smallest of the choices" which is fine but many other things can cause a loop to stop, so knowing the
size of the array can be helpful.
I am grateful for the reference to the Array Size primitive. It took me some time to find it, undoubtedly because it was the very first one in the Functions, Array, palette.
The biggest difficulty with graphic-based UI is in locating functions and controls. The help search always turns up 10 to 20 hits for every term I enter with terse titles.
I know, if it was easy, everybody would be doing it.
A "NULL" in many program languages is simply an empty element, not zero, not blank, just undefined. NULL entry do work their way into a surprising number of data sets but apparently not enough in LabVIEW for experts to be concerned about them.
Thanks for your consideration in responding.
01-16-2009 03:53 PM - edited 01-16-2009 03:54 PM
Heres another interesting piece of information pertaining to this topic.
If you have a for loop and you wire in an array, you dont neccessarily have to wire anything to N (specifying number of iterations)
The for loop will automatically iterate for each item in your array.
Also, if you wire a number out of a for loop, it will build an array outside of the loop,
consisting of the value of that number from each iteration
01-16-2009 04:32 PM
wildcatherder wrote:
A "NULL" in many program languages is simply an empty element, not zero, not blank, just undefined. NULL entry do work their way into a surprising number of data sets but apparently not enough in LabVIEW for experts to be concerned about them.
I know exactly what a NULL is. I just did not understand what you meant by the first NULL entry, or an array holding a NULL value. It sounded as if you wanted to know how to get an array to hold a NULL value, which didn't make much sense.
01-16-2009 04:35 PM
Cory K wrote:Heres another interesting piece of information pertaining to this topic.
If you have a for loop and you wire in an array, you dont neccessarily have to wire anything to N (specifying number of iterations)
The for loop will automatically iterate for each item in your array.
Also, if you wire a number out of a for loop, it will build an array outside of the loop,
consisting of the value of that number from each iteration
Ummm... yes, that's precisely what I and altenbach already said. Besides, the poster seems to already know what autoindexing is.
01-17-2009 11:09 AM
wildcatherder wrote:I am going through tutorials. That is how I am encountering these questions.
I am grateful for the reference to the Array Size primitive. It took me some time to find it, undoubtedly because it was the very first one in the Functions, Array, palette.
Smercurio, from this post, he sounded relatively new, so I was just trying to give him some tips.
I wasnt sure whether or not he already knew, so I figured it wouldnt hurt to say it anyway
01-18-2009 02:42 PM - edited 01-18-2009 02:43 PM
wildcatherder wrote:Does that mean the array is sized to the Index value with the first NULL entry?
In that case, would an array be able to hold a Null value (if Null has any meaning in this context)?
No, an array in LabVIEW is not something filled with pionters. The size of an array is determined in it's datatype in the first 4 bytes. (See How LabVIEW stores data in memory).
Off course can a value in an array be zero, or if you fill the array with references and you make those references invalid you would have NULLs.
You wrote:
In LabVIEW 8.6 a conditional terminal is added to the for loop if we want to break out.
Using this function has the preference over a while loop, if the output is auto-indexed. A for loop will optimize it's memory used based on 'N' (or smallest indexed array size).
Ton
PS you can read the actual 'N' inside the for loop to determine the smallest size of the indexed arrays, it might be different than the feeded 'N' on the outside