LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

variant example

Hello All,
      That pesky tab button... apologies for the half started earlier version.
 
You can see from the attached labview file I have collected a number of button and indicators into a cluster which are then collected into an array. It make the code a bit easier to read and organise on the front panel. I need to click on one of the buttons titled chan to fire up a panel containing calibration data.
 
The first question is can I replace the chan name on all the buttons with chan 1, chan 2, etc...?
Next you can see that I can detect which chan button is hit using the value from the array but I cannot figure out how to use the variant data produced. I have tried to generate a user friendly string without success. These variants are mysterious.
 
I suspect I am not really supposed to be solving the task this way else it would be easier, there is probably a simpler solution. I would like to stick with he large array unless it make the solution difficult. Ideally theres a string version of the variant. Gratefull for any pointers please.
 
Regards
 
Chris
0 Kudos
Message 1 of 6
(4,136 Views)
Chris,

The answer to the first question is "No." All elements of an array are identical except for value.

I am not sure what you are trying to do with the variant data. You can wire the Analog arr directly to the Flatten to XML without going through the variant. You can also flatten 'anything' to string, although the result is not human readable except for the text parts.

Lynn
0 Kudos
Message 2 of 6
(4,120 Views)
I don't know about the changing the button text for each instance of the array. 

I think the attached picture may be an easier way of determining which channel the "chan" button was pressed on.  See attached image:  Use an event structure, XORing the new values of "property" with the old values, search for the only true and you have the index of the cluster that was clicked on.
0 Kudos
Message 3 of 6
(4,116 Views)

Hello Lynn and JasonHill,

    Thanks for the help, I will have to try and find a tweak for the channel numbers. It seems a pity that such a usefull collection of text is exposed by the variant without the ability to convert it to a string, This would allow me to observe any array changes/clicks simply using string searches. I can see the xml features convert the variant but as you explained its not very usefull as various other repeating string data makes it difficult to isolate the info I would search for.

I did notice the 'variant to flattened string' generates a string and number array, which If i understand correctly is used to separate text and settings for file storage but I couldnt find any examples and felt this was getting a bit involved. I am not sure it would help anyway. I imagine someone has written a dll somewhere to input a variant and create a string showing the variant's text.

The fix suggested by JasonHill works fine (XORing), many thanks for that.

Regards

Chris

0 Kudos
Message 4 of 6
(4,102 Views)
Hi,
  unfortunately there's no easy way to get the text of what the Variant indicator is showing, since it's showing extra information related to the information it got, rather than the information being displayed being real data. In otherwords, the variant indicator shows you what it's received and what it thinks the data types are etc.
I know with Numbers there's the property node for the text version of what it's displaying, but at this time, there's no matching property node for variants since they don't usually show intelligable information.
 
In theory, you could get the image of the control (assuming it's big enough) and then run OCR over it, but that's as close as we can get to it and it's going to be very time and cpu intensive
Sometimes, the neatest wiring requires a more complex search algorithm and I think this is the situation you find yourself in.
Alternatively you have to typecast it to a u8 array and work out the data structure but that's undocumented and will take rather a long time to reverse engineer,
JasonHill's suggestion is the way to persue this.
 
There are topics on the forum about "activex text", but they all end on the note of not right now.
 
Hope that helps.
 
Sacha Emery
National Instruments (UK)
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 5 of 6
(4,070 Views)
Chris,
 
I was looking at your example VI code (thanks for that by the way!) and I am still unclear on what you are looking for.  If you need the data returned as simply a single string so you can search it using string functions cant you unbundle the data and convert to string yourself?  You could even make it a SubVI which just gives back the string to save diagram space.  Or, of course, you could just access the data directly after the unbundle.  This is assuming I understand correctly... Smiley Tongue
0 Kudos
Message 6 of 6
(4,061 Views)