LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I determine datatype of a control from it's reference??

    that's pretty much the question...

for example.  if I'm using an dynamic event structure, and an event fires....  I'd like to use the control ref that is given in the event structure to determine what type of control (numeric, boolean, array, etc.) changed...

is this possible...

more simply, if I have a reference to a control, can I determine it's type?

thanks
-z   
0 Kudos
Message 1 of 5
(6,800 Views)

Yes, read the "Class Name" property of the control to get the VI Server class name as a string.

-D

Message 2 of 5
(6,794 Views)
Thank you Darren,
    I should be more specific.  Is there any way to accomplish what I will describe below?

I have an event structure fire on an dynamic event.  The eventData node (on the left of the structure) has several outputs including "CtlRef" and "NewVal".  For a dynamic event, the data is of type varient and must be cast into the proper type using the  "Varient to Data" function.  Unfortunately, this requires that I put a constant in the code that is equivalent to the actual data type and wire it to the "Varient to Data" function....  What I would prefer is to somehow use the "CtlRef" value and wire that into the top of the "Varient to Data" function in order to properly cast the data.

ideas?

thanks
-z
0 Kudos
Message 3 of 5
(6,791 Views)

Unfortunately that's not possible.  What you could do, though, is use the Variant value and wire it into vi.lib\Utility\GetType.llb\Get Type of Variant.vi.  This VI will return an Enum value describing the datatype of the control.  You could then use that enum in concert with a case structure to convert the variant to the appropriate type.

-D

Message 4 of 5
(6,788 Views)

Another idea...

invloves using a "trial and error" method.

The "To more specific" node will return an erro if you atempt to cast the refence to the wrong type. Monitoring the error cluster will tell you if the control reference is of the type you have tried.

This idea is just offered as "food for tought".

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(6,755 Views)