01-20-2016 02:24 AM
Hi all
I'm sure this question has been posted many times before but I haven't found them.
Is is possible that user created VIs can change their output type like array VIs can do?
I'm using LV 2015 and wondering if this feature has been implemented in the latest LV version.
Thx
Ben
01-20-2016 02:38 AM
Hi Benjamin,
a subVI outputs the value that is generated inside!
So when you change the algorithm that generates the output value inside this subVI then your subVI will have a different output value…
But: as LabVIEW is a strictly typed programming language you cannot change the output type at runtime.
There are workarounds: You can use polymorphic VIs to reach that goal, you can use OOP to have such a behaviour, you can use a variant datatype, …
But: why do you need such a behaviour in the first place?
01-20-2016 03:53 AM
Aside from the very obvious 'the output values of a SubVI is determined by the code inside it' that GerdW mentioned, if you want to change the type of data coming out of a SubVI, you can do:
- Use polymorphic VIs (you create a VI for each variation of inputs/outputs and then can either select which one or have it adapt automatically to the wired inputs)
- Pass out a variant which you can then use with 'variant to data' to convert to the correct type
- Dynamic dispatch VIs with LVOOP
- An advanced technique is to create Xnodes (basically xcontrols for the block diagram) - but this is not officially supported by NI for users
There is also the subject of 'generics' - which are not supported in LabVIEW, but there are ideas for it on the ideas exchange.