From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying a malleable VI's output type depending on the presence of an input

Solved!
Go to solution

I would like to create a malleable VI with an optional input. If the input is not wired, the output should be a double, otherwise of the input's type. Just comparing the input to an empty variant constant won't do the trick since that's a runtime comparison, so I thought about asking a question here - which in turn made me think some more to come up with a trivial solution I thought worth sharing:

 

zero_or_passthrough.pngzero_or_passthrough.png

0 Kudos
Message 1 of 5
(3,035 Views)
Solution
Accepted by topic author tkienzler-tt

That won't have the desired effect if a Variant is wired to that input.  Why don't you just make the optional input a DBL with the correct default value?

Message 2 of 5
(3,016 Views)

Oh silly me... I somehow thought the terminals must be variants... Yeah, that makes it trivial, thanks! (For posterity's sake I got mislead by Programmatically Check If a SubVI Input Terminal Is Wired)

 

zero_or_passthrough.vimzero_or_passthrough.vim

0 Kudos
Message 3 of 5
(3,001 Views)

Sorry to resurrect a dead (and solved) thread!

 

I want to use a .vim to modify the output type depending on the input type wired in. Several functions appear to do this, such as Scan From String, but I cannot find any documentation to adapt the output type to be the same as an input.

 

I tried something like tkienzler-tt had in his OP, but I cannot see that it will work as it will just coerce the type to be a variant.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 4 of 5
(1,516 Views)

Ah! I actually tried it and it appears that Vims naturally force all outputs linked to a given input (even indirectly!) to be the same type as the input!

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 5 of 5
(1,512 Views)