To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example demonstrates how to create multiple Functional Global Variables and use them in an application.
Description
The functional global variable is a very useful tool when trying to make data globally available among multiple VIs, but can be taken further to not only store one data type, but multiple data types. Not only this, but it can also be used to perform software controlled timing within a VI. The attached Multi-FuncGlobal.vi performs all of these tasks, using the basic layout for a functional global variable, only with more cases, and more shift registers. Additionally, to avoid over-crowding the connector pane, the Multi-Functional Global Variable uses a cluster containing an enum and a variant as its input. This way, only one connector pin is used for all inputs when setting a value, be it number or string.
Requirements
LabVIEW Base Development System 2012 or compatible
Steps to Implement or Execute Code
1- Open and Run Multi Functional Global Variable 2012 NIVerified.vi
2- Use the Operation control to select the desired action (Set String, Set Numeric, Reset Time)
3- Test the stored values by changing the Operation control to (Get String, Get Numeric, Get Elapsed Time)
Additional Information or References
Multi Functional Global Variable 2012 NIVerified VI Block Diagram
Multi-FuncGlobal VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange. **
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
This concept in general is called the multi-functional VI, and is implemented in the LabVIEW Intermediate I course project. The outputs of the multi-functional VI can also be variants, allowing the VI to accept and return any data type. It's up to the caller to flatten the return to the correct representation.