Example Code

Using a Functional Global Variable to Communicate with a SubVI

Code and Documents

Attachment

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

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

Requirements:

  • 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

 

 

Screenshot_1.pngScreenshot_2.pngScreenshot_3.png

 "**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.

Comments
EWiebe
Active Participant
Active Participant
on

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
crossrulz
Knight of NI Knight of NI
Knight of NI
on

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.


GCentral
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