02-19-2013 10:51 AM - edited 02-19-2013 10:51 AM
Hello
I have an Unsigned word Ring control. The Values to the ring comes from output of another VI. The number of items vary all the time.
How is it possible to programatically order the items in the ringbox in alphabetic order ?
One can extract the string alone and order it alphabeically by sort 1d array function. But how to wire that one back to ring control to order it alphabetically? Is there any way to link the values to the strings?
Thanks
Solved! Go to Solution.
02-19-2013 10:57 AM
Your question does not make any sense. Since you know how to read the property node to get the values and know how to sort the array, where is the problem. You do realize that you can write to the property node as well as read it, don't you?
02-19-2013 12:44 PM
There is an easy way to do most of what you want. First, make sure that 'Sequential Values' is unchecked for the ring. Read the StringsAndValues[] property, sort it then write it back to the same property. This will sort on the strings and keep their associated numeric values intact.
The problem is that sorting does not put the strings in alphabetical order all of the time, lower case values come after upper case. If the strings have consistent case then you are fine. Otherwise you will need to convert the strings to upper (or lower) case before sorting and then map the values back to the original strings.
02-20-2013 03:08 AM
Thank you guys. Like Darin said it wrks perfectly for upper case values. For lower case values i converted them to upper case and sorted it then. But Is there a way to swap the the values? I mean to get a an output with new values and old item names? i.e sorted ring but with lowercases itself.
I treid to create a copy of the original ring and then did the Lower to upper case conversion . Now I have the values in alphabetical order but in UPPER case.
What i need is to arrange them on basis of new Values.
02-20-2013 04:10 AM - edited 02-20-2013 04:10 AM
I think this will do the job. Sorted!
02-20-2013 05:50 AM
Hi,
gooooooooood solution
02-20-2013 12:34 PM
My only quibble with the solution is that it is not always the first character which is capitalized. I would change the entire string.
02-20-2013 01:02 PM
Of course, you really don't need all that extra indexing baggage either just sort on the paired to uppercase cluster of rings and values
A good use of bundle and unbundle (not by name)
02-21-2013 04:25 AM - edited 02-21-2013 04:25 AM
@Darin.K wrote:
My only quibble with the solution is that it is not always the first character which is capitalized. I would change the entire string.
I agree, I just modified the OP's vi. Perhaps I should have pointed that out.