01-19-2012 02:56 PM - edited 01-19-2012 02:56 PM
Strange one today. Have a VI that rips through an INI file and looks at how many sections, keys, and the length of the keys in the file. It uses two nested for-loops, outer for the sections and inner for the keys.
If there's a section in the INI without any keys, the auto-indexed inner for loop doesn't execute. When this happens, the reference tunnel coming out of the inner for loop becomes "0" and the close-file VI after the outer for-loop coughs up an error when called.
I would have expected the for-loop to pass the value through instead of dropping it... if it happens with a reference, it could happen with data too. Is this something I'm doing wrong, am I expecting too much from LabVIEW, or is this a bug?
INI looks like this:
[Section One]
Sec1Key1 = "Value S1K1"
[Section Two]
Sec2Key1 = "Value S2K1"
Sec2Key2 = "Value S2K2"
[Section Three]
[Section Four]
Sec4Key1 = "Value S4K1"
"Section Three" is where the reference changes to zero because there's no keys in the section.

01-19-2012 03:00 PM - edited 01-19-2012 03:04 PM
Put a shift register on the reference. The loop will not execute so you get the default out of the tunnel. Edit: You should put the shift register on the inner and outer for loops. Edit #2 - you should also do this for the error cluster and any data passing through a for loop.
01-19-2012 03:13 PM
What Steve said is correct. In addition, what you are experiencing is expected behavior because if the auto-indexing array has a size of zero, the for loop will not run at all, and LabVIEW is unable to determine which values should be passed through (unless specified with a shift register) so it leaves it empty. You can see the behavior in the following image.
01-19-2012 03:20 PM
One more thing that you may or may not be aware of is that the for loop is lazy. It will iterate for the minimum number of times possible. If you have an autoindexed array with 10 elements and a 5 wired to N, it will iterate 5 times. If you have two autoindexed array inputs, one with 5 elements and one with 10 elements it will iterate 5 times. If you have any autoindexed array inputs that are empty then the for loop will not execute at all and you get default data out of tunnels.