10-09-2008 02:22 AM
Hello,
I have a variant that contains the label names and the addresses of different controls. What I would like to do is be able to read just the label names (In the screenshot, AO3 Address, AO4 Address, etc). I tried using a flatten to string but the data string contains the location of the physical address (not the label name). Is there an easy way to read just that first piece of infromation? I also tried using variant to data, but I'm not always sure what the data type is going to be. Thanks.
Solved! Go to Solution.
10-09-2008 02:55 AM
Morning Newbie
I have had a look at this and it would be great if you could post your code up as I am still slightly unclear as to what format you varient is in.
If you would attach a simple example then I will take a look and hopefully we can come to a good solution.
best regards
10-09-2008 03:22 AM
Hi there
you can't convert a variant to data without knowing the exact datatype. But you can use a reference to the cluster instead of the variant data to obtain the label names, the datatypes and the values of the cluster elements. see attachment.
10-09-2008 12:03 PM - edited 10-09-2008 12:03 PM
10-09-2008 12:58 PM
Hi there
The OpenG "Get Cluster Element Names" uses the data type descriptor. The format of this descriptor has changed from 7.x to 8.x, so you should be carefull when upgrading to 8.x.
LV help for "Type Descriptors":
Note The format in which LabVIEW stores type descriptors changed in LabVIEW 8.0. LabVIEW 7.x and earlier stores type descriptors in 16-bit flat representation. LabVIEW 8.0 and later stores type descriptors in 32-bit flat representation. The information for LabVIEW 7.x and earlier applies if you use the Convert 7.x Data mode of the Flatten To String function. The following information applies for LabVIEW 8.0 or later.......
Anyway: I was wrong, yes you CAN get the names from variant data without knowing the exact data type of the cluster.
10-09-2008 02:05 PM
Thanks for all the help and quick replies. The openG solution is exactly what I am looking for. Since I have a later version of LabVIEW (8.5), I haven't tried looking into it b/c of the caution about the type descriptor format changing.
Hopefully, there is another solution out there. I've included a sample program to illustrate what I am trying to do. By toggling a product selector control, I am able to update the label names on the variant data dynamically. The cluster data, however, stays static. If I could somehow read back the labels from the variant as a string, or some other way, that would be great. Thanks again!
10-09-2008 05:16 PM
10-09-2008 11:25 PM
What happens with OpenG and LV 8, is that the code is developed in LV 6, the open and upgrade functionality of LV makes sure the behaviour stays the same, so you should not have a problem (as smercurio found out).
If you find a case where it doesn't work please report it to OpenG.
Ton
10-10-2008 02:34 AM
06-02-2009 10:25 AM
You could also use the flatten to XML vi and pull out the names,see attached.
I don't do any errorchecking, and I am assuming you put in a variant of a cluster.
You could easily make it more versatile.
I use a subvi to insert data into a database, now I can save any cluster into any table, since I know the columns.
I like it better than the reference to a control, as the control values may not be updated, especially in a subvi.
-Nils