LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating front panel controls and indicators by reference


@altenbach wrote:

Maybe you can give a more global perspective why you even need that. An indicator is a data sink and should typically receive data at the terminal directly.

 

Your code only makes sense if this "indicator" is not even connected in the main code or is abused as data storage (i.e. fake "variable"), later to be read vial local variables or value property nodes elsewhere (yuk!).

 

Please explain.


I have attached an example of a UI that I would like to use in multiple VI's and it would indeed look like what you explained as a fake variable. How would you do something like this?

Download All
0 Kudos
Message 11 of 15
(444 Views)

Obviously, this is a simpler scenario where you only write. If you want to read/write in the subVI, you could do it as action engine, keeping the data in a shift register and read from there instead of the front panel terminal. All it should do is write to the terminal and keep the data local (not shown).

 

You current code could easily be simplified as follows (note that index array is resizable, returns the elements in order and that you can wire an error directly to the termination condition):

 

 

altenbach_1-1646937264015.png

 

Personally, I would even use an array of references (One connector instead of four!!!), especially since all are of the same type.

 

0 Kudos
Message 12 of 15
(428 Views)

@Ongelofeloos wrote:

@altenbach wrote:

Maybe you can give a more global perspective why you even need that. An indicator is a data sink and should typically receive data at the terminal directly.

 

Your code only makes sense if this "indicator" is not even connected in the main code or is abused as data storage (i.e. fake "variable"), later to be read vial local variables or value property nodes elsewhere (yuk!).

 

Please explain.


I have attached an example of a UI that I would like to use in multiple VI's and it would indeed look like what you explained as a fake variable. How would you do something like this?


This doesn't look like a "fake variable," but based on this example I wonder why you think that you need to do the UI update inside the subvi. Bring the loop outside of the subvi, ditch the references and DVRs, and pass the data points out to be updated at the terminals (I would likely pass them as an array).

 

As a side note, you can expand the Index Array to get more indices in one Index Array. Also, they will by default start at 0 and increment. No need for multiple Index Array primitives to index data from the same array.

0 Kudos
Message 13 of 15
(425 Views)

@altenbach wrote:

Obviously, this is a simpler scenario where you only write. If you want to read/write in the subVI, you could do it as action engine, keeping the data in a shift register and read from there instead of the front panel terminal. All it should do is write to the terminal and keep the data local (not shown).

 

You current code could easily be simplified as follows (note that index array is resizable, returns the elements in order and that you can wire an error directly to the termination condition):

 

 

altenbach_1-1646937264015.png

 

Personally, I would even use an array of references (One connector instead of four!!!), especially since all are of the same type.

 


That looks so much cleaner, thanks a lot. What would be the difference in doing this by reference or by variable?

0 Kudos
Message 14 of 15
(398 Views)

@Ongelofeloos wrote:
thanks for your awesome explanation. 

There's (also) kudos for that.

 

En weggeven is gratis!

Message 15 of 15
(385 Views)