From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control references/refnums: general info

Please forgive this question, I am a relatively new LV programmer and the help files & manual seem quite poor to me!
I am after some basic information about control references & refnums as I am sure they would be of help to me.

1. What are the main advantages in using them? (i.e. what they can achieve)
2. How are they implemented?
3. How is a control refnum/reference passed from one VI to another programmatically?

Huge thanks to anyone who may be able to shed some light on this topic.

Dan
0 Kudos
Message 1 of 2
(2,529 Views)
> 1. What are the main advantages in using them? (i.e. what they can
> achieve)


The references let you access properties and methods of controls on a
front panel. Previously, the access was limited to the diagram of that
panel, and each property node accessed a single particular control.
With control refnums, you can have one property node access an arbitrary
control with the refnum parameter controlling which one. You can also
send the refnums to subVIs meaning that the code can be abstracted to
simpolify your diagram and shared with other panels.


> 2. How are they implemented?


I assume you want to know how to use them. You right click on the
control or its terminal and under the create menu, next to where you can
create an implicit property node, you can also create a Reference node.
The datatype of this node is unique to the type of control that you
created it from, and when wired to a property node, the property node
will show the same properties as an implicit one. As an example, if you
have 8 Boolean buttons on your panel that need to be enabled, disabled,
hidden, colored, labeled, or whatever based upon the state of your
application. You can right click on the eight buttons creating
Reference nodes and build an array of the references. You can now loop
through your array and with one property node, set the properties of the
buttons based upon whatever logic or table of information that you need.
You can also do this in a subVI by passing the array of references to
the subVI.

It is also possible to get control refnums/references from other
properties. For example, a slider will give the reference to its
digital display, a graph will give references to its cursors, etc. It
is also possible to loop through the references of all objects on the
panel inspecting names or types rather than using the Create Reference
popup, but this is more advanced and requires casting the references.

If you really want to know how they are implemented, it is much like
file refnums or VISA refnums. I can give more info if you ask a more
specific question.


> 3. How is a control refnum/reference passed from one VI to another
> programmatically?
>


In the refnum palette there is a Control/VI refnum control. You drop it
on your subVI and right click to set the class. Note that there are
lots of classes arranged from basic to very specific. Class refnums
will convert to more basic automatically, but will not wire if they are
incompatible. So, if you are careful, you can select the class from the
menu and create the control refnum that you can wire to the connector
pane allowing you to pass refnums into the VI. A shortcut that is a bit
simpler is to draw the reference from the diagram to the subVI panel.
It will make the correctly typed control refnum for you, ready to wire
to the connector pane.

That is sort of the basic overview. You probably want to look at the
example -- general/cntrlref.llb/Property Nodes.vi. I also suspect that
the devzone contains other examples showing how they can be used.
Message 2 of 2
(2,529 Views)