Virus scan in progress. Please wait to download attachments.
This VI demonstrates a simple usage of Functional Global Variables in incrementing and displaying a number.
Functional global variables are VIs that use loops with uninitialized shift registers to hold global data. A functional global variable usually has an action input parameter that specifies which task the VI performs.
The VI uses an uninitialized shift register in a While Loop to hold the result of the operation. The following illustration shows a functional global variable that implements a simple count global variable. The actions in this example are initialize, read, increment, and decrement.
Every time you call the VI (Call Functional Global.vi), the block diagram in the loop runs exactly once. Depending on the action parameter, the case inside the loop initializes, does not change, incrementally increases, or incrementally decreases the value of the shift register. Although you can use functional global variables to implement simple global variables, they are especially useful when implementing more complex data structures, such as a stack or a queue buffer. You also can use functional global variables to protect access to global resources, such as files, instruments, and data acquisition devices, that you cannot represent with a global variable.
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code
To make this example work with your code, or as a standalone application:
Download the attached folder
Open the "Functional Global Variable_LV2012_NI Verified.lvproj" Project
Open the Call Functional Global Variable.vi
Run the VI
Initialize the value of the variable in the "Initialize to" control
Click on Initialize to store the value in the buffer
Click on Increment to Update the value in the buffer
Click on Get to display the value stored in the buffer
Additional Information or References
FVG used a SubVI
Block Diagram of FGV
**This document has been updated to meet the current required format for the NI Code Exchange.**
Todd S. LabVIEW Community Manager National Instruments
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.