LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reusing previous values!

Hi!

I would like my SubVI to return values from the previous call, unless one of
the input's
is True. I just placed all the "output" indicators within a case statement.
Is that a good
method. Are the indicators guaranteed to retain their values even between
calls to
the SubVI?

Thanks!
Atmapuri.
0 Kudos
Message 1 of 5
(3,584 Views)
The most common and probably safest is to use uninitialized shift registers to hold the previous data. This technique is frequently used e.g. to create "functional globals".
Message 2 of 5
(3,584 Views)
Hi!

> The most common and probably safest is to use uninitialized shift
> registers to hold the previous data. This technique is frequently used
> e.g. to create "functional globals".

This complicates the thing a lot. I have to create a separate vi and logic
to write and read from the vars... Are you sure that indicators
are not guaranteed to retain the values between iterations?

Thanks!
Atmapuri.
0 Kudos
Message 3 of 5
(3,584 Views)
This does not complicate things at all. Mads advice is totally correct, easy to implement and meets the requirements of a good programming practice.
http://digital.ni.com/manuals.nsf/websearch/5FBA64AD223A76A786256D2C00561F2D?OpenDocument&node=132100_US
0 Kudos
Message 4 of 5
(3,584 Views)
I don't see why you should have to "create a separate VI". You just have to place your VI's code within a While loop that never loops, use your case structure to select either the new data or the existing values from the shift registers, and wire the outputs of the shift registers (outside the While loop) to the indicator terminals.
0 Kudos
Message 5 of 5
(3,584 Views)