For debug purpose I am using "Unbundle by Name" to unbundle elements of a cluster to a 2D array and then writing that data to a spreadsheet file. As I go through the debug process, the channels of interest might vary causing me to change which elements are being unbundled. I would like to programmatically read the names of the elements being unbundled so I can include them in the spreadsheet file as column headers.
Is there a way to do this?
I have done something similar where I cast the data to a variant and then use the type information primitives to get the names. You can get this to work recursively, too, for clusters in clusters etc. VI scripting might also work for you, where you query the attributes of the unbundle function itself. I guess that there are better solutions though.
Depending on your debugging restrictions, you might get away with just dumping the whole thing into a json or xml file and do the selection on the receiving end. Or use an xml object as an intermediary from which to select the control and column header in one go. In more recent LabVIEW versions, a map may also prove helpful, however I cannot comment on them.
If this is for debugging and you don't need a super dynamic/robust solution, I would probably just feed the cluster and an enum (enum identifies cluster members) into a SubVI and output the requested item as a string. It's not really reusable as it's tied to a specific type of cluster but I would only go the data parsing route if it was the only option. In the functions palette these functions are under Programming > Cluster, Class, & Variant > Variant > Data Parsing.
All you have to do is wire the output of each unbundled element into one of these guys:
This palette contains a lot of other things as well, and they may be even more useful to you than this one.