08-29-2019 02:15 AM - edited 08-29-2019 02:24 AM
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.png
Solved! Go to Solution.
08-29-2019 02:26 AM
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?
08-29-2019 02:45 AM - edited 08-29-2019 02:51 AM
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.vim
10-26-2022 04:21 AM
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.
10-26-2022 04:43 AM
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!