12-22-2013 11:39 PM
Hi all,
I am designing a subvi to accept 4 inputs. 3 of them are DBL and the last one is boolean. the boolean input could be connected or not. If it does not feed with external value, then it will use those 3 DBL values to do the calculation but if it is feed by either true or false, a special value will be used for calculation. Now the question is how can I tell if that terminal is connected or not?
12-23-2013 01:01 AM
You can't.
As an alternative you can replace the boolean with an Int with default value -1 (just an example).
If the Int terminal is not connected the value will be -1 (and you can use the three DBL to do the calculation)
If the Int terminal is connected and set to 1 or 0 you can use the special values.
Regards,
Marco
12-23-2013 02:04 AM - edited 12-23-2013 02:06 AM
It's also possible in principle to use the DBLs themselves and then you don't need the fourth input - set each DBL's default value to an invalid value (like NaN) and then compare it to that value (if it's NaN then you need to use the Not a Number? primitive to compare). If it matches, then you didn't wire anything and you can use your special value.
If this doesn't work for you and you want to use Marco's method, then I would consider replacing the int with a typedef enum, where the default option is to use the special value, as this is clearer than the int.