LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass ring control to subvi

I've got kind of a two part question.  The first one is pretty straight forward and basicly a stripped down issue from my second question.  Is there a way to pass a ring control to a sub vi, have the sub vi manipulate the control (I.E. add ring strings, etc) and then pass the modified control back without losing control configuration?  When I pass it in I seem to lose all of my ring strings and then to return it it, it needs to be an indicator which means I obviously lose everything.

 

Second question is more difficult.  I have an array of clusters.  Inside the clusters is a ring control.  How can I pass this array to a sub vi and have it do the same thing I mentioned in question one?  I pass the array by refnum but I can't seem to find a way to dereference it to get at the clusters.

 

Sorry if this is a bit confusing.  If I need to clairify more I will.

 

0 Kudos
Message 1 of 5
(3,634 Views)

You've actually answered your first question with your second question: using references. References allow you to manipulate controls/indicators of parent VIs from subVIs. If you haven't seen it, there's an example that ships with LabVIEW called "Property Nodes". The easy way to get a reference:

  1. Right-click on the control/indicator (either on the front panel or the block diagram) and select Create -> Reference. 
  2. Drag the block diagram reference object onto the front panel of another VI. Voila! A reference control.

Note that there's no passing of reference "back" to the parent VI.

 

As to your second question: This one is more involved, as it requires typcasting the array element. Basically, you need to get the array element, cast it as a cluster, and then you can loop through its list of controls. When you get to the one with the name of the one you want you typecast it to a ring and modify its Strings[]. See attached example.

 

Side-Note: I don't know exactly what you're trying to do, but perhaps you should look into typedefs.

Download All
Message 2 of 5
(3,619 Views)

Thank you very much for the example VI's.  Typecasting is the missing link.  I see how you set the strings for all clusters in the array.  Let me ask one last question.  Is it possible for me to reference just one cluster from the array?  For example say I want to set the current value of just one control that's in one cluster, not all of them.  How do I dereference the array?  After that I know the same typecasting applies.

 

Thanks again.
0 Kudos
Message 3 of 5
(3,586 Views)

There is no dereferencing involved. You wire the reference to a Property Node and select the "Value" property. This will be the array, and you can use standard array functions to set an element of the array. Then, just write the new array back using another "Value" property node.

 

Message Edited by smercurio_fc on 09-05-2008 11:16 AM
0 Kudos
Message 4 of 5
(3,582 Views)
That worked like a champ!  Thank you for all the help.
0 Kudos
Message 5 of 5
(3,570 Views)