LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Default value output of for loop N = 0

You should be aware that tunnels are only a special case of a general rule, which is that "undefined" outputs will return the default value for the data type. This applies to things like USRs (which start out with the default, as that link shows) indexing past the end of an array, tunnels defined to use default if unwired (although that's explicit), outputs on nodes which don't execute because of errors, etc. I don't think that this is written anywhere, and I don't think it's even technically an absolute rule, but in practice that is the way LV behaves. It would be nice to have it officially documented, but I would suggest it's the kind of thing which you should generally not rely on (although there are exceptions).


___________________
Try to take over the world!
0 Kudos
Message 11 of 19
(1,120 Views)

@Bokor wrote:

Formally speaking this help talks about shift registers and not tunnels.

 

But since the behaviour is clear, I stop beating a dead horse 🙂

 

And yes, calling the support is also an option. I should find my code somewhere 😉

 

Have a nice day everybody!


Oops, you're absolutely correct.  I just think of them as the same thing because I'm constantly converting tunnels into shift registers.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 19
(1,099 Views)

@tst wrote:

You should be aware that tunnels are only a special case of a general rule, which is that "undefined" outputs will return the default value for the data type. This applies to things like USRs (which start out with the default, as that link shows) indexing past the end of an array, tunnels defined to use default if unwired (although that's explicit), outputs on nodes which don't execute because of errors, etc. I don't think that this is written anywhere, and I don't think it's even technically an absolute rule, but in practice that is the way LV behaves. It would be nice to have it officially documented, but I would suggest it's the kind of thing which you should generally not rely on (although there are exceptions).


I think it actually has to be something close to, if not completely, an absolute rule.  IMHO anything else would make LabVIEW dangerously inconsistent.  BUT that is why I always make sure there is a value chosen by me for each case of a case structure for, unless I truly know that I don't (and won't ever) care what the value is for each undefined case.  And that's hardly ever.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 13 of 19
(1,096 Views)

I totally agree with your opinion AltenBach.

 

I can't imagine who wrote this stuff.

It is as if it were translated from Chinese to English!

 

The help file is full of these kinds of confusing statements.

 

 

0 Kudos
Message 14 of 19
(1,082 Views)

@AKA_TG wrote:

I totally agree with your opinion AltenBach.

 

I can't imagine who wrote this stuff.

It is as if it were translated from Chinese to English!

 

The help file is full of these kinds of confusing statements.

 

 


Agreed, but it's full of really good stuff, too.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 19
(1,070 Views)

Here's an elaboration on the "Default value output of for loop N=0" theme for classes:
Zero Iteration For Loop and class tunnel - bug or feature? - NI Community

0 Kudos
Message 16 of 19
(484 Views)

wiebe@CARYA wrote:

Here's an elaboration on the "Default value output of for loop N=0" theme for classes:
Zero Iteration For Loop and class tunnel - bug or feature? - NI Community


Access denied!

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 17 of 19
(471 Views)

wiebe@CARYA wrote:

Here's an elaboration on the "Default value output of for loop N=0" theme for classes:
Zero Iteration For Loop and class tunnel - bug or feature? - NI Community


That is on the Champion's private board.  You might want to just post a summary of the last few posts from that thread.


GCentral
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
0 Kudos
Message 18 of 19
(464 Views)

@crossrulz wrote:

wiebe@CARYA wrote:

Here's an elaboration on the "Default value output of for loop N=0" theme for classes:
Zero Iteration For Loop and class tunnel - bug or feature? - NI Community


That is on the Champion's private board.  You might want to just post a summary of the last few posts from that thread.


My bad...

 

Here's my content (guess I'm allowed to share that):

 

wiebeCARYA_0-1647589719615.png

 

Note that the N=0 For Loop returns a default object, while the disabled structure returns the default wire type.

 

The N=0 For Loop and Preserve Run-Time Class do the same...

 

So if the control input is a Parent.lvclass, and a Child.lvclass is wired to it, the PRC and N=0 FL return a default Child.lvclas, while the DDS returns a default Parent.lvclass.

 

In the above example, I've used this to detect if an object is the type (e.g. is a child object wired or not).

0 Kudos
Message 19 of 19
(450 Views)