Example Code

Determining LabVIEW Data Type from Variant Form

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example uses some of the Variant utility VIs to determine the datatype contained in a variant.

 

 

Description

Converting from Variant Data to LabVIEW Data with the Variant to Data function requires knowing the type input beforehand. This example helps determine the LabVIEW data type using the GetTypeInfo VI.

Since the output for the GetTypeInfo VI in the case of an array is "Array", the code uses additional VIs to determine the array element data type.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code

Run the VI

 

 

Additional Information or References

Use only the first GetTypeInfo VI if the generic data type is acceptable and use additional GetArrayInfo and GetTypeInfo VIs to determine the array element data type.

The GetTypeInfo & GetArrayInfo VIs are located in the vi.lib/Utility/VariantDataType folder.

 

Block Diagram

BD.PNG

 

Front Panel

FP.PNG

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Best Regards,
Swathi B

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
mike_schrbr
Member
Member
on

Hi

I have been studying for the CLAD exam && when I was going through your files trying to get tuned in on type descriptors  it occurred to that the descriptions only elaborated the data types, which made sense to me since data can originate from a control or be sent to an indicator. But what I havent figured out yet is how LabVIEW differentiates between a contol & an indicator.

In C++ as example the input, (w/o Visual C++) is Cin &

                                 the output (w/o Visual C++) is Cout.

I would think that it would be necessary to have a similar construct, or way to discern a control icon from an indicator icon.

Any thoughts?

Michael.E.Schreiber@Boeing.com

Valarauca
Member
Member
on

I was wondeirng if there was possibility of you releasing the password to this VI. I'm currently trying to write a functional programming suite for labview, and it would be helpful if I could view the source of this VI.

Wes_P
Member
Member
on

If you mean the Variant GetTypeInfo VI, this user didn't create it - it ships with LabVIEW and NI are the ones that locked it.

Wes Pierce
Principal Engineer
Pierce Controls
Philipp N.
Member
Member
on

Just use the open G libs, they have the VIs open to decode variants