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 Shortcut Menu Plug-Ins

cancel
Showing results for 
Search instead for 
Did you mean: 

Adapt SubVI Inputs.llb

Author: Brian Hoover (LabVIEW Champion)

 

Description

The purpose of this right click VI is to programatically adapt input and output control types on a subVI, to the wired inputs.  What this means is if you wire a data type to a subVI that it doesn't accept, running this right click can create a new VI copied from the existing one, which will replace the controls with ones that match the input wired in that instance of the subVI.  It can also just replace the controls with the VI without making a copy, but that could have bad effects if that subVI is used in other places, because you are changing the data type of that VI in all instances of it, because there is only one copy on disk.

 

This can be very helpful in creating polymorphic VIs.  As demonstrated in this video you can add new polymorphic types to the OpenG functions.  This right click does not drill down into subVIs of subVIs replacing controls and indicators.  So this is most useful when your subVI uses lots of NI primatives that accept multiple data types.  It is possible it could be made to drill down into subVIs but at the moment that adds a lot of complications.  For situations like that I think it would be best if the subVIs just accepted variants (like most of the OpenG functions do) and then use one last variant to data on the subVI, which gets its type from one of the inputs.

 

Usage

The right click will only appear on subVIs on a block diagram, when the VI has a broken wire (usually meaning the wrong type) or a coercion dot indicating a type change.  If you select Adapt SubVI Inputs Save As... it will prompt for a place to save the new VI.  Then it will copy the existing VI to the new location, replace the input controls to the types wired on the block diagram, update the indicators to be the type wired, and then replace the original subVI that you right clicked with the new one.  If you select Adapt SubVI Inputs it performs the same steps mentioned before, but it doesn't make a new VI copy, it just edits the one selected.

 

https://www.youtube.com/watch?v=IKRlEgR8juA

http://www.screencast.com/t/AFbM6PbjJN

 

There are probably bugs, but I just threw this together and is my first real right click function that performs a decent amount of scripting.

Contributors