LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically change control/indicator data type

Solved!
Go to solution

Is there a way to change a control or indicator's underlying data type?  I have a VI that I want to use that will accept any data type (basically varriant data) and display it accordingly.  I have different controls selected to display data of different types in the sense of integer data vs decimal data vs boolean but some data types will be of type uint32 vs int16 vs uint64 etc.  Is there a way to programatically change the data type so I don't need to have every combination of indicator?

0 Kudos
Message 1 of 5
(4,464 Views)
Solution
Accepted by topic author cchock_idg

The short answer is no. The long answer is that LabVIEW has no "generic" controls that allow you to display any data type (aside from the variant obviously). There are several ways of attempting to overcome this but all require you as the programmer to explicitly handle every data type that you could possibly encounter. Here are a few possibilities (in no particular order), please let me know if you would like help implementing any particular one of these.

  1. Force incoming data to variant, use the variant info to determine the data type of the original data in a case structure (Open G can make this VERY easy), have an indicator on the front panel for every desired data type and hide the unused ones
  2. Use a sub-panel on the front panel and call into sub-vi's to display the specific types (this lends very well to encapsulating your data into a class and would let you use OOP to extend to different data types)
  3. Use a tab control with the variant (similar to option 1) put each data type indicator on its own tab, enable only the current
  4. Make an X-Control to accept a variant and do either option 1 under the hood
  5. Format everything as a string and use a string indicator

That's all I can think of right now, again, let me know if you'd like more info/help on any of the options.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 2 of 5
(4,458 Views)

Hi Charles

 

Some weird combination of 1 and 2 is what I'm currently doing, I was just wondering if there was a way that would prevent me from having to create separate indicators for the various UINT, INT and floating point variables which I guess is my next task.  Thanks for the quick response.

0 Kudos
Message 3 of 5
(4,442 Views)

There is something called Malleable VIs in versions 2017 and above.

Go through the link given below once.

https://www.mediamongrels.com/introduction-to-malleable-vis-labview/

Hope this helps 🙂 

0 Kudos
Message 4 of 5
(3,171 Views)

You can check the data type of a variant and use this connected to a Case structure to convert it to a string for a 'catch all' indicator. 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(3,159 Views)