LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant to Data with Null handling sub vi

Solved!
Go to solution

Hi all,

 

I'm creating an application which uses a DataSocket to output Variant Data.  I then transform the Variant back into its 'real data' form (Booleans, U8, DBL) using the 'Variant to Data.vi', this works fine when there is data coming from the DataSocket however if no data is present an error is received (error code 91).  I've added a check to see if there is no data present using the below code, however as there will be over a dozen instances of this code throughout my program converting Variants to a mix of; Booleans, U8's and DBL's I want to put this code in a Sub VI, as I believe this would be neater and is what real programmers do.   

 

My problem is the 'Output Data' needs to be able to adapt to the 'Type' input before run-time (as the 'Variant to Data.vi' does), however I haven't been able to figure out how to do this.  Does anyone have any suggestions on what I need to do to achieve this? 

 

Thanks in Advance,

 

Mark

 

Using LabVIEW 2010 Full Development System

0 Kudos
Message 1 of 3
(3,470 Views)
Solution
Accepted by topic author Holroyd

Wrap the function in a case structure and use Empty String/Path? function with the variant wired in to determine if the variant is empty.  Only execute the Variant to Data if it is not empty.

 

Edit:  It looks like you've added an image since I posted and doing what I proposed.  I'm not sure of any way you can really wrap this up in a subVI with different types.  If you have a limited number of different types, you could possibly make a polymorphic VI.

Message 2 of 3
(3,437 Views)

@Ravens Fan wrote:

If you have a limited number of different types, you could possibly make a polymorphic VI.


Raven,

 

Polymophasism seemed to do the trick! I'd heard the name banded around other forums previously but wasn't sure how to implement it.  After a good old Google all became clear!

 

Cheers for pointing me in the right direction!!


Mark

0 Kudos
Message 3 of 3
(3,420 Views)