Mahbod Morshedi Posted December 25, 2023 Report Share Posted December 25, 2023 Hi All, Is there a way to unbundle a cluster by "order number" instead of name? Cheers, M Quote Link to comment
ensegre Posted December 26, 2023 Report Share Posted December 26, 2023 something along these lines? Quote Link to comment
Darren Posted December 26, 2023 Report Share Posted December 26, 2023 What is your use case for needing this behavior? Quote Link to comment
Mahbod Morshedi Posted December 26, 2023 Author Report Share Posted December 26, 2023 14 hours ago, ensegre said: something along these lines? Hi. Thank you for putting this together. It is not like this actual unbundle but like indexing an array, using the cluster control order to unbundle the item to get it as a control like unbundle by name does. cheers M Quote Link to comment
Mahbod Morshedi Posted December 26, 2023 Author Report Share Posted December 26, 2023 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 Quote Link to comment
Darren Posted December 26, 2023 Report Share Posted December 26, 2023 If your cluster contains elements that are all the same data type, you can use the Cluster To Array function. If your cluster contains elements that are different data types, then the approach you describe won't really work due to LabVIEW's strict data typing. 1 Quote Link to comment
X___ Posted December 28, 2023 Report Share Posted December 28, 2023 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? 1 Quote Link to comment
hooovahh Posted January 2 Report Share Posted January 2 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. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.