05-04-2021 07:44 PM
@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...
05-04-2021 09:21 PM
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.
05-04-2021 09:56 PM
It's a lot easier to abuse local variables than shift registers though!
05-05-2021 04:45 AM - edited 05-05-2021 05:00 AM
@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:
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...
05-05-2021 10:02 AM - edited 05-05-2021 10:07 AM
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.
05-05-2021 11:28 AM
@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...
05-05-2021 01:14 PM
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.
05-05-2021 03:30 PM - edited 05-05-2021 03:30 PM
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.
05-06-2021 02:50 AM
@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.
05-06-2021 02:55 AM
@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 🤗.