03-26-2014 07:23 AM
lets say a subvi takes in as input whether the input is a vi path or a vi reference and the path/reference.
what is the best control for the input that decides whether a path/reference is being provided ?
i've considered using a boolean (say true for path and false for reference) but it does not seem intuitive (is there any way of making it seem intuitive?)
enum can be used too but that seems a bit too much for a simple 2 way conditional thingy;
string constant input requires string matching which is again overdo
(i've attached a vi for reference & to add clarity)
Solved! Go to Solution.
03-26-2014 07:41 AM
There are a few ways to handle this.
The polymorphic would probably be the best way to do this.
03-26-2014 07:47 AM
Hi
In these cases, I have several times been able to determine internally whether to use the path or path reference. -This works if you can say "if both are valid, I always want to use x" or if you can say "only one of these will ever be passed a valid value". In these cases, you can use "is path/refnum" type primitives inside the VI to determine which input is valid, and if both are valid, to pick one. Make sure to use "not a path" and empty ref controls as default values in your VI.
I realize this is not quite what you are asking and that you might already have considered this option?
I modified your example to show one way to do this... err.. but I can't add files? So I stitched together some screenshots.
(Note I left two indicators on there just to show the logic better.)
03-26-2014 07:47 AM
bah crossrulz beat me to the punch while I was screen shotting.
03-26-2014 08:18 AM
It seems like a better API choice in this case might be to use 2 VIs, either seperate or a polymorphic VI. If you look at the Write File VIs in LabVIEW they use a polymorphic solution to this (admittedly natively)