LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Default Value Of Anything

Is there any VI that inputs anything and outputs default value of same type? 0 for numbers, empty string for strings, empty array for array, cluster of default values for clusters, empty variant for variant, default object for objects etc. (Maps, refnums, waveforms...)

 

Or at least if there was a VI to compare a given value to default value with boolean as output.

 

Of course I can code it for each case, but maybe I am missing something.

 

Thanks!

0 Kudos
Message 1 of 4
(806 Views)

There is a number of ways. I usually use a zero-iteration For Loop.

0 Kudos
Message 2 of 4
(802 Views)

If you want a subVI that can do this for anything, consider using a VIM (Malleable VI).  You should only have to code it once, then it adapts to the type.

 

There is also one other thing you need to consider if you are trying to convert "anything" to a default value:  What happens when a LabVIEW class is passed in?

 

Because the default value could, depending on interpretation, either be based on the wire for the class used on the diagram (i.e. the parent only), or it could be the default value for whichever child class is riding on the wire at runtime.

 

If you want the first option, that's what most things give you (i.e. zero-iteration FOR loops, etc.) but if you want classes to use whatever is on the wire, you should use a LabVIEW object passed into a "preserve run-time class" node:

Kyle97330_0-1654618411400.png

 

Message 3 of 4
(783 Views)

Actually, a zero-iteration For Loop also gives the Child class default object (somewhat non-intuitively).  

0 Kudos
Message 4 of 4
(760 Views)