LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Mads

Replace with New VI

Status: New

There is one thing I am missing in the Replace menu. It seems logical to have an option there to replace the VI (or missing VI) with a NEW VI.

 

Every now and then I come across code that is missing a subVI and the VI is nowhere to be found so I end up opening the VI with a question mark in the place of the missing SubVI. Now, I can see that LabVIEW knows what the connector pane of the missing subVI was (the used part of it anyway), and I just want to replace the question mark with a VI with the same connector pane. However, no "Replace with New VI" option exists.

 

There are two ways around this already, but none of them are as smart as they could be. The most obvious is to just creae a new subVI and use the replace function, but then I will have to recreate the connector pane manually. The second option (which did not occur to me until I began thinking about this idea) is that you can just click on the question mark and select "Create SubVI" from the Edit menu. LabVIEW will then do what I want - namely to create a new VI with the same connectors as was used for the missing subVI - job done. However, it will also place the question mark inside the new subVI and nag about it being missing. I can cancel the missing VI dialogs, delete the reference to the old VI inside the new one, and I am ready to rebuild the missing VI, but why not just have a replace with new option? 

 

The missing subVI is an infrequent case, so why bother? Well, this is not just handy for missing VIs. It will simplify things any time you want to replace an existing VI by creating a new one. Sure, you can save the existing VI with a new name, replace the old one with it, and then start changing the new one..But with this option it could all be done in one go.

 

 

ReplaceWithNew.png

 

 

 

 

 

11 Comments
Mads
Active Participant

The Insert option you have if you right-click on a wire is another place where the New VI option would be nice. Instead of inserting an existing VI you should also be able to select Insert New VI. The new VI would then automatically have the selected wire(s!) as control(s) and indicator(s) on its front panel.

AristosQueue (NI)
NI Employee (retired)

You describe the "Save As" workaround... it already can be done "in one go". Just save as the VI using the "update callers" option in the save as dialog.

Mads
Active Participant

Yes that is an available option, but not "in one go":

 

With the replace with new option you have:

 

1. Right-click on VI

2.Replace with new VI

 

Instead of:

 

1. DoubleClick on SubVI (not an option when it is a missing one either so it covers less use cases too. Extra idea: Put a save as option in the contextual menu when you have selected a VI...)

2. Open File menu

3. Select Save As

4. Select Substitute copy for original (what if you just want to replace that single instance/reference?)

5 Click OK.

 

Admittedly the Replace with New option will still require you to save the VI later on, but the flow of the work is less interrupted and more similar to a create SubVI operation e.g. Adding New VI to the replace function also fits nicely with other places, like the above mentioned Insert.

 

 

JÞB
Knight of NI

I haven't even read the comments before I kudos'd it... Genius!  Espicially New... from templateSmiley Surprised  High level shell code gets DOCUMENTED with type discriptions and tips- gosh- can this be "with NEW"> class, Project, Autopopulating Folder, Project Library, DAQmx TASK.....

 

Oh my head hurts.... YES!


"Should be" isn't "Is" -Jay
crelf
Trusted Enthusiast

I'm trying to wrap my head around rthe actual use case(s) here - so, you've got a missing subVI, and you want to replace it with a new subVI, right?  The only time I could think of this occuring is when you should have the original subVI on disk that you don't, so you want a temporary workaround until you do have the original subVI - in which case you could just use a diagram disable structure and put your temporary code in the enabled case of that.  Or am I missing your use case entirely?





Copyright © 2004-2024 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 4.0 License.
Mads
Active Participant

The example use case which is the one you are commenting on is indeed a bit special. The VI is missing and you will *not* ever get i back so you have to make a new one. As described in this thread this option would reduce the work involved in such a task.

 

However, in general this is useful whenever you need to replace a VI with a new one. That's the 5 to 2 steps reduction listed above. AND it is useful as a generally available option - e.g. on the insert function. You could then select a wire or multiple wires - and click insert to get a VI that has the given inputs and outputs.

 

Logically it is a natural thing to have available too ("hey, I want to replace this with a new VI so I just do it on the spot from the right-click menu right..." Likewise for insert. So it makes LabVIEW more intuitive to use.

AristosQueue (NI)
NI Employee (retired)

For the non-missing VI case, I would suggest it is better to start from the existing VI and do Save As so that you pick up options like thread priority, reentrancy, default front panel control style, etc. I'm still inclined to see this as an idea only for missing subVIs, though I do like it for missing subVIs.

Darin.K
Trusted Enthusiast

Assuming that Create SubVI now mangles the wiring and connector pane less, you could use one of the new hooks to fix the BD of the created VI if it only contains a missing VI.

Davidek
Active Participant

Mads pointed me to this idea from my own suggesting that it was similar. Couldn't you just select the missing VI and do Edit->Create SubVI, click ignore when LV tries to search for the missing VI and then delete the missing VI in the new subVI? Now you have a new VI with the same inputs as the old one with very little hassle. This is what I've done in the past.

Mads
Active Participant

That workaround is described in the idea:

 

"The second option (which did not occur to me until I began thinking about this idea) is that you can just click on the question mark and select "Create SubVI" from the Edit menu. LabVIEW will then do what I want - namely to create a new VI with the same connectors as was used for the missing subVI - job done. However, it will also place the question mark inside the new subVI and nag about it being missing. I can cancel the missing VI dialogs, delete the reference to the old VI inside the new one, and I am ready to rebuild the missing VI, but why not just have a replace with new option? ".

 

It's more consistent and intuitive to have a replace with new VI option, and in many ways an option to create a new VI based on a wire selection is it's natural big-brother....I just happened to miss the smaller brother at the time Smiley Happy