LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
X.

Left shift register initialization: required/recommended option

Status: New

Left shift registers (For Loop, While Loop) can be either initialized or not.

In general, the programmer knows what is needed for the correct behavior of the code, but code modification (say a broken wire followed by a Ctrl-B) can change this status:

 

 

Step 1:

Screen Shot 2015-11-09 at 18.35.55.png

Step 2:

Screen Shot 2015-11-09 at 18.38.12.png

Step 3:

Screen Shot 2015-11-09 at 18.37.59.png

 

If this last step is performed without remembering that the shift register needs to be initialized for the rest of the code to function properly, an insidious bug can result.

 

My suggestion: Let the user specify whether a shift register initialization is required or not (just like a VI connection can be specified)  

 

4 Comments
Intaris
Proven Zealot

How about a "Shift Register Initialisation terminal" like we can have for Feedback Nodes?

X.
Trusted Enthusiast
Trusted Enthusiast

This has been proposed already and is slightly different from what I am suggesting.

I am not concerned about "first" versus "later" calls. I am concerned about potential bugs created by undefined states (or missing connection to upstream code) due to code editing.

This is the purpose of a "required" VI terminal. Think of a sihft register storing a refnum for instance. If there is no "i=0" initialization case in the loop, the initial state is undefined, but more importantly, the upstream source of the refnum has been disconnected, which is what, as a programmer, I want to be protected against.

altenbach
Knight of NI

A somewhat related idea that however tries to solve a slightly different problem. (probably not a duplicate!)

 

X.
Trusted Enthusiast
Trusted Enthusiast

Yes, I read it before posting. It is different and tries to solve a totally different problem.