LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rearrange Case Bug when using enum

When you create a Case Structure using an enum as a case selector, I would expect the "Sort" button to alphabetically rearrange the case. Instead nothing happens, as in the case illustrated below.

 

ScreenHunter_002.jpg

 

According to the Help:

 

 

  • Sort—Arranges the cases in alphabetical order. User-defined cases surrounded by quotation marks appear at the bottom of the list. For example, True appears before "Foo" in the case list.

 

Of course, it does not say anything about the situation when the quotation mark surrounded cases are in fact the names of different values of an enum. But since I can't "Sort" my enum in alphabetical order (first because there is no such tool for enums and second, because in doing so I would totally mess up the one-to-one relationship between enum case name and enum value), I am stuck with a totally messy list of cases, which is a pain to work with.

To add insult to injury, even though the "Sort" button will not do anything in this situation (as I just explained), it is still active and frustratingly ineffective. At least gray it out!

 

As a disclaimer, I do not have a very high opinion about the "Rearrange Case" dialog windows in general, but this is a particulartly frustrating bug, when you have a screenload of cases to skim through...

 

Tested in the latest and greatest.

 

Message 1 of 7
(3,600 Views)

I didn't look closely into this, but it looks like it's sorting the enum by numeric value. Whether or not that behavior is correct or it should follow the documentation, I leave to you. Personally, I think I prefer the by-value sorting.


___________________
Try to take over the world!
0 Kudos
Message 2 of 7
(3,576 Views)

Hi

 

1. when you wire a string input to the case selector and Sort using the Rearrange cases, it sorts perfectly well a per the Alphabetical order.

 

2. when you wire a numeric input to the case selector (say an I32 number) and Sort, the cases are sorted as per the Numerical order. what should be the alphabetical order when a numeric input is wired?

 

when you wire a combo box, it is a string value that is wired to the case selector. so, it follows point 1.

when you wire an enum, it is a numerical value that is wired. it is not a string value. so, it follows point 2.

Regards
Freelance_LV
TestAutomation Consultant
Message 3 of 7
(3,570 Views)

@Freelance_LV wrote:

Hi

 

1. when you wire a string input to the case selector and Sort using the Rearrange cases, it sorts perfectly well a per the Alphabetical order.

 

2. when you wire a numeric input to the case selector (say an I32 number) and Sort, the cases are sorted as per the Numerical order. what should be the alphabetical order when a numeric input is wired?

 

when you wire a combo box, it is a string value that is wired to the case selector. so, it follows point 1.

when you wire an enum, it is a numerical value that is wired. it is not a string value. so, it follows point 2.


Need not be. When you wire an I32 number you will get the case name as an I32 number itself but when you wire an Enum the case value will be a string that is defined in the Item fields. Remember Enum is a seperate data type and I believe we cannot compare with numeric data type (Correct me if I am wrong)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 7
(3,566 Views)

Well, Freelance_LV is correct about the desciption what happens.

Enum are user friendly, readable "tags" that hide a numeric value. So an enum for internal data storage is an integer (shown with blue color). The confusion in this post is, that all controls/indicators and the case structure show the tag name instead of its numeric value (which increases readability, but hides the data type).

 

I concur with X. though that the help is misleading on this rather special data type 'enum' and could be improved. So maybe you want to file a suggestion on this?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 7
(3,561 Views)

I have already suggested to completely revamp the "Rearrange Case" dialog, so I am not going to repeat myself and certainly don't think that "correcting" the Help file will do anybody any good.

0 Kudos
Message 6 of 7
(3,528 Views)

There is really only one rule.  Rearrange cases always sorts by value.  In the case of an enum, the value is the numeric value, not the string.

0 Kudos
Message 7 of 7
(3,509 Views)