A Word About SubVIs


If you want to take full advantage of LabVIEW's abilities, you must understand and use the hierarchical nature of the VI. A subVI is simply a stand-alone program that is used by another program. After you create a VI, you can use it as a subVI in the block diagram of a higher-level VI as long as you give it an icon and define its connector. A LabVIEW subVI is analogous to a subroutine in C or another text-based language. Just as there is no limit to the number of subroutines you can use in a C program, there is no limit to the number of subVIs you can use in a LabVIEW program (memory permitting, of course).

If a block diagram has a large number of icons, you can group them into a subVI to maintain the simplicity of the block diagram. You can also use one subVI to accomplish a function common to several different top-level VIs. This modular approach makes applications easy to debug, understand, and modify. We'll talk more about how to build subVIs later, but it's such an important part of the LabVIEW programming environment that we want you to keep it in mind as you're learning the basics.

LabVIEW does not let a VI call itself as a subVI (a technique known as recursion). LabVIEW also does not let a VI call subVIs that use it as a subVI (at any level of the VI hierarchy). If you attempt to place a subVI that would violate this rule, LabVIEW will display a dialog stating that recursive use of the VI is not allowed.


There is an advanced technique that uses VI Server and the Call By Reference Node to allow a reentrant VI to call itself dynamically (recursively). You can learn about VI Server and the Call By Reference node in Chapter 15, "Advanced LabVIEW Features."





LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net