LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

whether its really bad to set uninitialized shift register

Solved!
Go to solution

Hello Everyone!

 

Just two short and probably dummy questions, hoping u would pls answer it and thx very much!

 

1. Is it really not good to set a shift register without initialization? What will be the result? Since I read fr many books and they all said it is better to initialize shift register whenever u set one.

 

2. Is there any case that we need the uninitialized shift register?

 

Best regards!

0 Kudos
Message 1 of 6
(3,857 Views)

1) Each time you run a VI, the shift register begins with a value of 0. If you do not initialize the shift register, the loop uses the value written to the shift register when the loop last executed or, if the loop has never executed, the default value for the data type.

 

2) yes, we can use an uninitialzed shift register to preserve state information between subsequent executions of a VI.

0 Kudos
Message 2 of 6
(3,854 Views)
Solution
Accepted by topic author sophiey

@sophiey wrote:

Since I read fr many books and they all said it is better to initialize shift register whenever u set one.


What kind of books are you reading??? 😮

 

The decision to initialize or not, depends on the desired functionality. There is no global "better" at all. It depends what you want to do.

 

Uninitialized shift registers (or globally initialized feedback nodes) provide the core functionality of action engines. One of the most useful programming tools. Get familiar with it and your skills will increase dramatically!

Message 3 of 6
(3,848 Views)

Thx, so it will not report the error such as "can not connect because of undefinition", I will learn it as fast as possible!

 

Also, sorry but the words that I learnt is from some chinese typical textbooks...

0 Kudos
Message 4 of 6
(3,813 Views)

Hi Sophiey,

 

To initialise or not to initialise is the question.  The guys were absolutely right.

If you want to start a loop (FOR or WHILE) with a new value, you want to initialise it.

If you want to use your VI as a FGLB (Functional global : stores data in stead of global variable or local var), don't initialise it.  YOu want to use the previous data that was stored in the shift register when you last ran the VI.

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Message 5 of 6
(3,791 Views)

Hi,

 

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.

Message 6 of 6
(3,776 Views)