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: 

How to make user created VIs to change their output?

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

Stay Hungry, Stay Foolish
0 Kudos
Message 1 of 3
(2,555 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,545 Views)

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.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 3
(2,524 Views)