Jump to content

Unbundle cluster by order?


Recommended Posts

2 hours ago, Darren said:

What is your use case for needing this behavior?

Hi Darren,
Well, admittedly, it is my lack of experience with programming.
I wanted to use one wire to carry all my data, so I made an array of clusters, a variant typed and a tag string' to' and did a tag search to find the data and get the variant. To convert that back to my data, I will have to have the original data type feed to "var to data". I want to get this done programmatically. Case structure is a no-go, so I was thinking of bundling all the data, finding the order of the data via the tag, and unbundling that way. Now, I think it was my naivete, and I should not be so lazy and manually do it when I add a new data type.

 

Cheers

image.png.fe84cd681b9665a4a4dc24ec60f737a6.png

Link to comment
On 12/26/2023 at 2:45 PM, Mahbod Morshedi said:

I wanted to use one wire to carry all my data, so I made an array of clusters, a variant typed and a tag string' to' and did a tag search to find the data and get the variant. To convert that back to my data, I will have to have the original data type feed to "var to data". I want to get this done programmatically. Case structure is a no-go, so I was thinking of bundling all the data, finding the order of the data via the tag, and unbundling that way. Now, I think it was my naivete, and I should not be so lazy and manually do it when I add a new data type.

Have you considered variant attributes?383584297_VariantAttributesExample.png.b82076ce1d9e6550e7de360fecfeba85.png

  • Like 1
Link to comment

In general it is just best to make your cluster a type def (which links all the places that data is used, similar to a defined struct) and then unbundle and bundle the data as needed.  Since LabVIEW is a strictly typed language, getting all data from something like a cluster means it will have to return them as variants.  And then what do you do with that?  Well you'll need the Variant to Data, and specify the type it should turn into.  If it is the wrong type you get an error.  So while you can get all elements of a cluster in an order, the usefulness of it might be limited.  If you are doing something like taking a cluster then writing it to a file, or reading it from a file and you want it to be somewhat human readable, then this might be useful way of doing it.  These functions already exist in the OpenG Variant Configuration File toolkit.

  • Like 1
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.