Jump to content

How to recover variant type info


Neil Pate

Recommended Posts

I have a variant, for some reason it does not seem to have it's type information inside, the variant thinks it contains a variant (which I don't believe it does). I cannot do anything about this, this is how it is being handed to me.

Does anybody know how I can retrieve the original data type? (do not really need to know specifics of SGL or DBL etc, just want to know it is an array).

In the example attached I know this particular variant is an SGL array, so the Variant-->Data works fine as I have manually put in the type. However I am expecting various different array types.

Variant Trouble.vi

Capture.PNG

Capture2.PNG

Link to comment

Using the Variant to data, turn it into an array of variants.  If it returns no error, then your input is either an array, or a cluster.  This trick can also turn a cluster into an array of variants so you'll need to check for that too.  Maybe check to see that all the data types of the output are the same?  But even that isn't a guarantee.  How did you end up with an array that thinks it is a variant?  Maybe there is an unnecessary To Variant in there some where.

  • Like 1
Link to comment
2 minutes ago, hooovahh said:

How did you end up with an array that thinks it is a variant? 

Courtesy of the OPC-UA API that comes with the DSC toolkit.

I did try to check for a variant in a variant, but it seemed to keep going down the rabbit hole. I will try the variant to array of variants I do use this elsewhere.

At the moment this is getting me out of jail, but it feels wrong on so many levels. The OPC-UA toolkit kindly tells me what the data type is, it just does not bother putting that into the variant.

Capture3.PNG

Link to comment
21 minutes ago, hooovahh said:

Using the Variant to data, turn it into an array of variants.  If it returns no error, then your input is either an array, or a cluster.

Bingo! Seems to work. I think all my clusters will be properly named as they will come from my code, it is only the arrays which come from the OPC-UA toolkit that may have this problem. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.