LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant data type

I'm trying to do some variant data type but clearly there are problems. I attached the block diagram screenshot here and hopefully someone can point out where the problem is. The To Variant function is not working, value after this one is not right.

 

Thanks,

 

Guangde Wang

0 Kudos
Message 1 of 7
(4,791 Views)

Hi Guangde,

 

would it help to wire the boolean itself instead of a reference to a boolean to the "to variant" function?

The reference is not the boolean value - it's (kind of) a pointer to the boolean Smiley Wink In your code you get the reference value converted to variant and forced back into a boolean...

Message Edited by GerdW on 04-07-2009 11:07 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(4,781 Views)

Hi Gerdw,

 

Thank you for responding to my post. The purpose here is to send the reference to a subVI and convert the subVI to a DLL. The DLL will not recognize RefNum data type. So I have to convert it into a string, send it to the subVI then convert it back to a RefNum. That's why I'm testing this function. Still, this is the first time I'm trying to use variant data type, I don't have a basic idea how it works.

 

Guangde

0 Kudos
Message 3 of 7
(4,771 Views)

You need to use the Unflatten From String function rather than the To Variant function since your input is a flattened string.

 

Tip: If you want a strict refnum you can right-click on the wire going from the Boolean reference all the way on the left to the To Variant function and select Create -> Constant. This will give you a strict refnum. This is useful if you need to access the Value property as in this case the datatype will be Boolean rather than a variant.

 


The DLL will not recognize RefNum data type.
Really? I did not know that.  I would have thought a refnum would be treated as just an integer, since that's basically what the value is. Hmmm... will need to look into this one.

 

0 Kudos
Message 4 of 7
(4,754 Views)

smercurio_fc wrote:
Hmmm... will need to look into this one...

I did. I created a simple subVI that looks like this:

 

I then created a DLL out of it. I then used the Import Shared Library Wizard to import my DLL back into LabVIEW so I could call it. The refnum gets housed into a cluster, but it does work. No flattened string needed. Whether or not in the end it's "cleaner" than using a flattened string I'll leave that to you to judge. 

Message Edited by smercurio_fc on 04-07-2009 05:10 PM
0 Kudos
Message 5 of 7
(4,750 Views)

Hi smercurio,

 

Thank you for your post and attached png. I didn't find these To and From String functions in the beginning. After seeing your screenshot, I found these functions and tried them, they worked okay and now I can send a RefNum to a DLL just like sending it to a subVI, of course I have to flatten it first.

 

Thank you again for your help,

 

Guangde Wang

0 Kudos
Message 6 of 7
(4,728 Views)

guangdew1 wrote:

now I can send a RefNum to a DLL just like sending it to a subVI, of course I have to flatten it first.


The point of my last post was that you actually don't. You can certainly take this route, but it's not a requirement.

0 Kudos
Message 7 of 7
(4,688 Views)