LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Functional Global Variables: can an indicator be used instead of a shift register?

Solved!
Go to solution

 

Note: values of Controls on the connector pane are *not* preserved between calls.  If wired, they receive the value wired in.  If unwired, they revert to default value.

 

I'm not 100% certain what happens with controls that aren't on the connector pane, they may well preserve their value but since they aren't wired, their preserved value and their default value are likely the same anyway.

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 11 of 16
(1,085 Views)

Controls that are not connected to connector pane terminals do retain their values in between calls so long as they remained in memory.



0 Kudos
Message 12 of 16
(1,080 Views)

JonP wrote:

My personal conclusion: A guiding principle in my lengthy software experience (not so lengthy with LV as you can probably tell!) is to keep the code as simple as possible. In the case of a simple Get/Set FGV (no need to read the indicator) I think using the indicator is the simplest solution but I agree that for anything else the single-iteration loop (how can that not be a kludge) with a shift register or, a bit better, use of a feedback node is probably best.


In the case of a Get/Set FGV, the simpleest solution is to just use a Global Variable instead of the FGV.  It performs a lot better and the Get/Set FGV does nothing to help the issues with a global.


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
Message 13 of 16
(1,070 Views)

Yes, that's a good point, although there can still be benefits to using an FGV, for example if you store multiple values that are dependent on each other or if you have to perform some operation on the data before returning it (in which case I guess it ceases to be a simple get/set FGV I suppose, although it is simple enough that I would still implement it my way).

0 Kudos
Message 14 of 16
(1,061 Views)

I'm in "partial agreement" with your conclusion.  Several years ago, I proposed adding a "Do Once" loop to the Structures palette specifically to allow you to have shift registers ("memory") for Action Engines and Functional Globals.  When I try to tell students about wiring True to the Stop terminal of a While loop, their eyes glaze over ...  Needless to say, this was largely pooh-poohed (though one NI Guru Who Shall Remain Nameless was sympathetic), with Feedback loops being touted.  However, I must admit that I find that a feedback loop representation of a FGV is nowhere near as "intuitive" as a While+Stop+Shift Register construction ...

 

Bob Schor

0 Kudos
Message 15 of 16
(1,049 Views)

@Bob_Schor wrote:

Needless to say, this was largely pooh-poohed (though one NI Guru Who Shall Remain Nameless was sympathetic), with Feedback loops being touted.  However, I must admit that I find that a feedback loop representation of a FGV is nowhere near as "intuitive" as a While+Stop+Shift Register construction ...


This has been a long debate between Stephen (hates feedback nodes) and Darren (loves feedback nodes).  Personally, I like the feedback nodes.  But to each their own.


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 16 of 16
(1,044 Views)