You should always use shift registers for refnums, errors and any other value which you want propagated in the event of a zero iteration For Loop. The upper version of your What about..? picture (minus the case selector) would work.
All you have to do is use a shift regiter for the reference. If you think about it, it makes total sense. I'll have to see if I can dig up a good reference to this.
As for your extra comment, that's what a case structure if for. It should not be merged with the for loop. That would be too confusing.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions Unofficial Forum Rules and Guidelines "Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Here's a link to a LAVA thread on this discussion. The link will take you to the answer.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions Unofficial Forum Rules and Guidelines "Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Well, it is not really an "else" case, but a "zero iteration" case, which would be triggered by feeding a zero to N or having any of the autoindexing input arrays be of zero size.
As has been mentioned by others: In the case you show, using shift registers is sufficient to maintain the error and reference data, so having zero iterations will work correctly, no special case needed.
The important question is now if there are any legitimate cases where we actually want some real alternative code (not just wired across!) to be executed if there are zero iterations?
At this time, I don't see a scenario where that would be useful.
When I first posted this thread, I was expecting a full of Kudos that I can't even hold around my arms. But the reality was completely opposite
altenbach,
Thank you for getting to this point. Even if I did not know the shift-register could do enough in my example, it does not mean 'else' case is completely useless. There are cases where you do something else other than just wiring it through. But now I think such situations are rare and a case structure can be used for that purpose.
Should LabVIEW do more to help users get this right? If we had a better warning system, should tunnels on these by warnings? Should refnums and errors default to creating shift registers instead of tunnels? Would that behavior only be on for loops or should while loops do it too (since while loops always run once they don't have quite the same problem but errors particularly can still be important)? Are there other types that are better served by shift registers?
This idea is probably not a good place to brainstorm these concepts but if you can define a good heuristic for LabVIEW to decide between tunnel and shift register, you can always post it as another idea.
Any idea that has received less than 3 kudos within 3 years after posting will be automatically declined.