Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 66767

Darren's Occasional Nugget 03/25/2014

$
0
0

I attended the European CLA Summit last week (my first trip outside the USA!). At the summit I gave a presentation that discussed, among other things, the VariantDataType VIs. Among the myriad use cases for these VIs is checking a variant to see if it matches a particular type. For example, we have a VI that ships with LabVIEW that will assess whether or not a variant is an error cluster (for reference, this VI lives in vi.lib\addons\analyzer\_analyzerutils.llb\VIAnUtil Check Type If ErrClust.vi):

 

checkerrclust.png

 

In this VI, we check the variant to see (1) if it is a cluster, (2) if it has three elements, and (3) if those elements are Boolean, I32, and String (in order). I have often recommended this approach for type checking over a simple Variant To Data function call, since Variant To Data will attempt the conversion, even if the types don't match exactly:

 

vartodata.png

  

Another great use case for these VIs is programmatically retrieving, at runtime, the names of enum entries as a string array:

 

enum.png

 

The VariantDataType VIs are great for data type parsing, and these are just two of many use cases that demonstrate the power of this undocumented API. Have you encountered a novel use for the VariantDataType VIs in your applications?

 


Viewing all articles
Browse latest Browse all 66767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>