Using a Shift Register in Multiple Executions Produces Different Results

Updated Sep 14, 2023

Reported In


  • LabVIEW

Issue Details

When I run my VI that uses a shift register, it works the first time. However, when the VI stops executing and I run it again, it gives an incorrect result. Why is this happening?


This is usually caused by uninitialized shift registers. To initialize a shift register, wire an initial value to the shift register by wiring from the outside of the loop to the terminal of the left shift register.

If the shift register is not initialized, the shift register is set to a default value when it is first loaded into memory. The default value depends on the data type of the shift register: an empty array for arrays, 0 for numeric types, and an empty string for strings. 

After the VI runs, the shift register will keep the last value saved in it. When the VI is run again, the shift register only resets to the initial value if an initial value is wired to it or if the VI was removed from memory by either closing LabVIEW or programmatically removing the VI from memory. If there is not an initial value, the last value from the previous execution of the VI is used. The following picture shows an empty while loop with initialization of an array, numeric, and string shift registers:

More information about shift registers can be found in the LabVIEW Help
(Contents»Fundamentals»Loops and Other Structures»Controlling Repetitive Operations Using Loops»Transferring Values between Loop Iterations).