Example Code

Using a Functional Global Variable to Communicate with a SubVI

Code and Documents


This demo uses a Functional Global Variable (FGV) to communicate with a subVI.

The main VI launches the subVI using VI Server.  It then writes a value to a FGV.


  • LabVIEW 2012 (or compatible)

Steps to Implement or Execute Code:

  1. Run the Main VI.
  2. Change the Numeric control.
  3. Observe the changes in subVI.

 Additional Information or References




 "**This document has been updated to meet the current required format for the NI Code Exchange.**" 

Bryan H.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Active Participant
Active Participant

Is this also possible if I start the subVI from an external packed library? It tried and it started, but tranferring data from MAIN to SUB (which comes from packed lib) did not work.

Eugen Wiebe
Bernstein AG
CLAD - Certified LabView Associate Developer
Knight of NI Knight of NI
Knight of NI

The problem you will run into with the PPL is that the PPL has its own copy of the FGV.  Therefore, you will not be communicating between a VI outside of the PPL and one inside of the PPL.

There are much better ways to pass data around than with a FGV.  Even a simple Global Variable I would argue is better than this implementation of a FGV (only Set and Get states). See this article for more information about what I'm getting at: A Look At Race Conditions.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5