What are the main use cases?
Passing data through cases of a state machine or event structure
This is the most common use case.
- This simple state machine uses two shift registers – one for the next state to execute and one for the data stored during execution.
While/for loop performing calculations using a previous value or multiple previous values.
- This example shows a multi-element shift register. Each time the for loop executes, the new value is stored in the top element of the shift register, the last element in the top is passed to the middle, and the last middle element is passed to the bottom.
Functional global variable – using an uninitialized shift register to hold data.
When a shift register does not contain an initialization value, it’s default value is whatever value was added to the shift register the last time the VI was executed. Not understanding this behavior can lead to some undesirable outcomes since you aren’t controlling what value is used during the first iteration of the while loop. However, this behavior can also be leveraged in what is known as a Functional Global Variable. By expecting the shift register to contain the last value you entered into it, you can store data for the next place that the VI is called. Functional Global Variables are typically used when the user wants to perform complex scaling or calculations on data as it is stored, read or store data in multiple different places throughout an application, or in situations where the user wants to buffer multiple readings. They form the basis for simple OOP-like objects in LabVIEW without needing the full capabilities of OOP. Some people used the term “Action Engine” for these types of VIs.