LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

generate a subvi out of a vi

Hi together,

I would like to generate a subvi out of an exisitng program (vi) to use it in another vi (the main program).
Can anybody tell me which is the easiest way to do it?
I tried it with "Creating subvi's from selections", but then the following message appears:
"The selection contains a front panel terminal in a For Loop or While Loop. If you create a subVI from the selection, the functionality of the original VI might change. Do you want to create a subVI?"
I'm not sure what this means or how I can avoid it? I would like to create a subVI out of the whole existing program, that's why I have to select everything?!

Thanks for your help, haven't ever created a subVI so far...

Steffi
0 Kudos
Message 1 of 9
(3,504 Views)
Hi Steffi,
did you try it, after the message pops up? If you do it, you can open the new created vi, go then to the "old" main vi and use "Strg+Z". So you have no changes in your original program and can check the new sub vi.
Mike
0 Kudos
Message 2 of 9
(3,497 Views)
Steffi,

If you want to create a subVI with everything in it, why not just Save As... to a new name?

Lynn
0 Kudos
Message 3 of 9
(3,492 Views)
Hi steffi,
 
Actually... a sub-vi is a vi.  What makes it a sub-vi is calling it within a vi.
 
That being said.  Simpy go to your Front Panel.  Right click the icon at top right and show terminals. 
Connect your controls (to the left) and your indicators (to the right) of the connector pane.
Place the vi inside the other vi that will call this one, and voila... A sub-vi.
 
Remember to use common practices such as using the bottom corners for error in & out. 
I always use the top corners for either references (control, VISA, etc) or if none, for paths.  The middle ones for values (numeric, string).
 
You do not need to use create subvi from selections.  It has been years since I touched that... It never does it the way I like, anyway.
 
Try this and let us know how it went..
 
RayR
Message 4 of 9
(3,489 Views)
I like the create sub-vi function.  I don't have enough imagination to create the sub-vi without looking at the main VI Smiley Very Happy
But you are right about it never being done the way you want.  Always have to re-do the connector and layout.
Jim

LV 2020
0 Kudos
Message 5 of 9
(3,475 Views)
Hi Jim,
 
LOL!  It's actually easier than you think.  I find that the time that it takes to redo the connectors and clean the layout is faster to do it from scratch.
 
It think of the vi (that becomes a sub-vi) as a function that I can reuse.  It then expands from that.  🙂
0 Kudos
Message 6 of 9
(3,464 Views)
To answer the original question:

@steffi.kono wrote:

I tried it with "Creating subvi's from selections", but then the following message appears:
"The selection contains a front panel terminal in a For Loop or While Loop. If you create a subVI from the selection, the functionality of the original VI might change. Do you want to create a subVI?"
I'm not sure what this means or how I can avoid it? I would like to create a subVI out of the whole existing program, that's why I have to select everything?!

This message appears when your selection contains a front panel control, as the message says. For example, if you were to select the following (Note: this is non-working code for demonstration only):

and then select "Create SubVI" you'd get the message. If you select "Yes", you end up with this:


This may or may not be what you want to do. LabVIEW isn't sure, so it's basically warning you. Whether or not what it generates is correct is up to you to determine.


Message Edited by smercurio_fc on 05-14-2008 09:02 AM

Message Edited by smercurio_fc on 05-14-2008 09:02 AM
Download All
0 Kudos
Message 7 of 9
(3,453 Views)
Thanks to everybody for your help!
RayR: This is exactly what I wanted to have, thank you!: ) Didn't know how to solve it, but with your explanation it worked fine: ) Thanks a lot.

Steffi
0 Kudos
Message 8 of 9
(3,375 Views)
Glad you found a solution..  🙂
 
RayR
0 Kudos
Message 9 of 9
(3,351 Views)