LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shift register and local variable..which is more suitable??


@pbisson wrote:

Just bear in mind, a local variable is actually just a pointer to the original storage location (the control), so it's really only just a 32/64-bit address.


A Local Variable causes a copy of the control data and they are quite a bit slower than using shift registers.  And let's not even get into the race conditions...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 11 of 20
(723 Views)

Yes indeed, one can misuse any data structure. But each has its positive and negative attributes. Good coding balances these attributes when solving any particular problem, IMHO. So I cannot speak for exclusive use of one technique over another. It's not wrong to use a local variable, nor is it wrong to use a shift register, each has its uses. Really, this is the point of my first post.

0 Kudos
Message 12 of 20
(715 Views)

It's a lot easier to abuse local variables than shift registers though!

Rolf Kalbermatter
My Blog
0 Kudos
Message 13 of 20
(716 Views)

@altenbach wrote:

wuliao23 wrote:
in the program, it have a case structure inside a while loop, which is true at the initial of the program, and i need to make this case become false at the next loop..

Maybe you don't need either. 😄
 
If you want a case to execute only for the first time after the start of the program, use the "first call" primitive from the synchronization palette. Check the online help to make sure it's what you want.


That works, of course.

 

It's not a 1-1 replacement for the shift register though. First call will be true each time the VI is run after being idle. A shift register will remain it's state over several runs.

 

This can get weird with dynamic VIs. 

 

You can choose the behavior with a shift register:

First Call.png

 

The top one will behave like a shift register, the bottom one like a First Call? node.

 

Not that it's better or worse, just pointing out more options...

Message 14 of 20
(697 Views)

Put all the constants that are separately wired into shift registers into an "uber-cluster" and wire through with shift register.  Delete the first offending shift register to cause broken wires.  Hunt down each place where it is broken and unbundle/bundle as needed.  Lather, rinse, repeat with the next shift register...

 

I hope it goes without saying that you should be typedef'ing it - and hopefully all those constants are typedef'd as well.

 

EDIT:

The uber-cluster can quickly become unmanageable.  I would suggest making smaller clusters with related constants.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 20
(676 Views)

@billko wrote:

Put all the constants that are separately wired into shift registers into an "uber-cluster" and wire through with shift register.  Delete the first offending shift register to cause broken wires.  Hunt down each place where it is broken and unbundle/bundle as needed.  Lather, rinse, repeat with the next shift register...

 

I hope it goes without saying that you should be typedef'ing it - and hopefully all those constants are typedef'd as well.

 

EDIT:

The uber-cluster can quickly become unmanageable.  I would suggest making smaller clusters with related constants.


Or learn proper OO...

0 Kudos
Message 16 of 20
(660 Views)

wiebe@CARYA wrote:

@billko wrote:

Put all the constants that are separately wired into shift registers into an "uber-cluster" and wire through with shift register.  Delete the first offending shift register to cause broken wires.  Hunt down each place where it is broken and unbundle/bundle as needed.  Lather, rinse, repeat with the next shift register...

 

I hope it goes without saying that you should be typedef'ing it - and hopefully all those constants are typedef'd as well.

 

EDIT:

The uber-cluster can quickly become unmanageable.  I would suggest making smaller clusters with related constants.


Or learn proper OO...


Yes, this for someone who has a hard time understanding local variables.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 17 of 20
(649 Views)

Why is this 13 year old post being resurrected? Original poster got advice and hasn't been heard from, someone replied with advice, there is no new question or discussion relevant anymore.

 

Old Post.png

Message 18 of 20
(636 Views)

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

Put all the constants that are separately wired into shift registers into an "uber-cluster" and wire through with shift register.  Delete the first offending shift register to cause broken wires.  Hunt down each place where it is broken and unbundle/bundle as needed.  Lather, rinse, repeat with the next shift register...

 

I hope it goes without saying that you should be typedef'ing it - and hopefully all those constants are typedef'd as well.

 

EDIT:

The uber-cluster can quickly become unmanageable.  I would suggest making smaller clusters with related constants.


Or learn proper OO...


Yes, this for someone who has a hard time understanding local variables.


Well, you won't need those anymore 😁.

 

I keep saying that I use OO because it's easier, not because it's harder. But you're right, some effort has to be put into learning it.

 

Using a class as a type def cluster is a good way to get started with OO.

0 Kudos
Message 19 of 20
(612 Views)

@StevenD wrote:

Why is this 13 year old post being resurrected? Original poster got advice and hasn't been heard from, someone replied with advice, there is no new question or discussion relevant anymore.


Good point. No idea. Ask pbisson. It's often not obvious that a thread (or OP) is old once someone replies to it.

 

The discussion might be relevant to someone.

 

We can always start a discussion on relevance of this discussion 🤗.

0 Kudos
Message 20 of 20
(608 Views)