Discussion:
Finding control type from control reference
(too old to reply)
C .DOT
2008-08-08 11:40:05 UTC
Permalink
I have a stric type control (A) on the front panel of a VI. This control is a cluster made up of a number of instances of another strict typed control (B). Later control (B) is also a cluster made up of two controls, a check box and an enum. In the VI there is a value change event handler for control A. (I have included the check box to conrol B, it previously had only the enum). There is existing code in that event handler that works on the enum control. When I check a box, event handler is called and it tries to detect which enum's value has been changed. Since none has been changed, it enters into an endless loop.What I want to do is use the CtlRef (terminal?) of the event handler to execute the previous code if the control is enum, otherwise do nothing. (I'll place the code in a case structure). How can I find the controls type from CtlRef?What are those things inside the event handler called (e.g. OldVal, NewVal, CtlRef)?Thanks a lot for your time!Have a very nice weekend!
JoeLabView
2008-08-08 12:40:05 UTC
Permalink
From what I understood of the description you provided, it appears that you are looking for the class ID of the controls.  Each control type has a class ID.
You can get the class ID's from the controls within a cluster.  
To see if I understood correctly, please see the attached example.  If it is not what you are looking for, please provide clarification (and do not rate my post).
Thanks.
R
Oops..  I didn't answer the 2nd part of your question.
OldVal is the value before the value change.  NewVal is the new Value (causing the value cvhange) CtrlRef is the control reference of the control whose value changed...  well... actually the one you selected to trigger the event case.  I mentionned value change because of the description.  Events can be triggered by other means than a value change..  Just wanted to make sure there's no confusion....  :oMessage Edited by JoeLabView on 08-08-2008 08:33 AM


ClassID.vi:
http://forums.ni.com/attachments/ni/170/347836/1/ClassID.vi
C .DOT
2008-08-08 13:10:06 UTC
Permalink
Dear friend <a href="../view_profile?user.id=2483" target="top" class="auth_text" style="font-weight: bold;"> JoeLabView</a>! Thanks a lot for your answer. Are class IDs fixed? I mean do all check boxes have a single ID or IDs change for each instance?Why can't I rate your reply? Is it for me alone or for everyone?Is there a chart someplace where I can find the class ID corresponding to the control name (as we humans call them)?Have a sweet weekend!
MikeS81
2008-08-08 13:10:08 UTC
Permalink
Hi C.DOT,
see this link: <a href="http://digital.ni.com/public.nsf/allkb/3AC5A0C63F748E19862569D000769718" target="_blank">http://digital.ni.com/public.nsf/allkb/3AC5A0C63F748E19862569D000769718</a>
&nbsp;
Hope it helps.Mike
C .DOT
2008-08-08 13:40:07 UTC
Permalink
Thanks a lot <a href="../view_profile?user.id=88992" target="top" class="auth_text" style="font-weight: bold;"> MikeS81</a>! That was an answer to one of my questions.Do all Boolean's have the same ID (8). So class ID does not differentiate between different types of Boolean's?
johnsold
2008-08-08 14:10:05 UTC
Permalink
Here it is saved for 8.0. Class ID properties are fixed. All Booleans have the same ClassID. You can look at the labels to tell which is which. I do not see any property to distinguish between types of booleans. Things like button size could give you a clue, but since sizes can be changed, it would not be very reliable.What are you trying to differentiate? I cannot see why you would need to know programmatically whether a boolean is a button or a toggle switch.Lynn
C .DOT
2008-08-08 14:10:08 UTC
Permalink
Dear Lynn! Thanks for the VI (aham! you forgot to attach it, please attach it, I'll be so grateful). Differentiation between booleans is not such a critical issue. I just wanted to expand my knowledge.
JoeLabView
2008-08-08 15:10:10 UTC
Permalink
C .DOT wrote:Why can't I rate your reply? Is it for me alone or for everyone?&nbsp; I wanted to avoid what happened with someone else ;)&nbsp; Please disregard..&nbsp;



Did you have a look at the example I posted?&nbsp; You can expand from it.&nbsp; You could place a check box, and have a look at it's class ID.&nbsp; You can also look at the properties of each chack box.&nbsp; You should be able to retrieve it's label (name) which can then be used to identify it with it's reference.
&nbsp;
R
johnsold
2008-08-11 12:40:08 UTC
Permalink
Sorry about missing the attachment. Try again. Lynn


Cluster event test.vi:
http://forums.ni.com/attachments/ni/170/348224/1/Cluster event test.vi
C .DOT
2008-08-11 13:10:06 UTC
Permalink
Thanks a lot for the trouble, <a href="../view_profile?user.id=32263" target="top" class="auth_text" style="font-weight: bold;"> johnsold</a>!
johnsold
2008-08-08 13:10:05 UTC
Permalink
You can use the reference to the outer cluster (A) to get references to the inner clusters (B) by using the Controls[] property node. You then need to repeat the process from a B reference to get a reference to the enum. If all the clusters (B) have the same name, I am not sure how you identify which one you are checking. You can also set up events for inner controls in the clusters.The LV help refers to those things as Event Data Nodes. The help is not too helpful on usage however.Here is a little example.Lynn


Cluster event test.vi:
http://forums.ni.com/attachments/ni/170/347839/1/Cluster event test.vi
C .DOT
2008-08-08 13:40:06 UTC
Permalink
Dear <a href="../view_profile?user.id=32263" target="top" class="auth_text" style="font-weight: bold;"> johnsold</a>! Could you, kindly, save the VI for version 8.2 and reattach. I'll be so grateful. I'll let you know if I need more clarification after using the VI. Thanks a lot for the VI (and help)!
DFGray
2008-08-11 13:10:07 UTC
Permalink
I am late to the party, but have a bit of useful info for you. The ClassID property should be an invariant with LabVIEW version.&nbsp; ClassName is another property that gives you the same information, but has been known to change from LabVIEW version to LabVIEW version.&nbsp; Use ClassID if you go this route.Another option is to use the GetType utilities buried in vi.lib.&nbsp; In LabVIEW 8.2, they can be found in &lt;vi.lib&gt;\Utility\GetType.llb\...&nbsp; These were created to make it easier to solve the issue you are currently facing.&nbsp; They have not been exported to the palette, so there are no guarantees they will keep their current interface (it is still the same in LabVIEW 8.6) and quality may be below our normal standards, although I have had no problems with them.
JoeLabView
2008-08-11 14:10:09 UTC
Permalink
Thanks DFGray,
I didn't know about that utility.&nbsp; I will check it out.
R
smercurio_fc
2008-08-11 15:10:08 UTC
Permalink
<a href="http://www.openg.org" target="_blank">OpenG</a> has similar functions in the Data Tools library. One VI provides an enumeration output for the various datatypes.
johnsold
2008-08-12 20:10:08 UTC
Permalink
C. DOT, I did not thnk it was any trouble until I clicked the Back arrow after posting that example. Then my hard drive crashed.I have posted hundreds of times without crashing a hard drive, so I really do not think the posting had anything to with the crash.Currently using an old, slow, computer in the lab.Lynn
Continue reading on narkive:
Loading...