04-07-2009 03:48 PM
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
04-07-2009 04:06 PM - edited 04-07-2009 04:07 PM
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
In your code you get the reference value converted to variant and forced back into a boolean...
04-07-2009 04:28 PM
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
04-07-2009 04:49 PM
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.
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.
The DLL will not recognize RefNum data type.
04-07-2009 05:09 PM - edited 04-07-2009 05:10 PM
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.
04-07-2009 07:25 PM
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
04-08-2009 09:03 AM
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.