LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"-" character in enum not allowed?

Solved!
Go to solution
Highlighted

Hello,

 

If I create an enum with the following items:

"+", "-", "/" and "*", I cannot see the item "-" on the front panel as an option.

Is it a restricted character to use in enum type? Before you say, I know I can just use a Ring type, but I just would like to learn why I see this behaviour?

thanks!

 

EDIT: same behaviour for the Text Ring....

EDIT2: Menu Ring: also problem with "-"

 

enumtest1.jpg

enumtest2.jpg

0 Kudos
Message 1 of 11
(2,326 Views)
Highlighted

I don't think its restricted, probably a bug with Enum and Ring. Try to set the " - " as Last or first element of the Enum and select the "Line/divider" that appears when you pull the drop down, you can see the value " - " appears. I guess the "-" is replaced by a line/divider (Bug).

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 11
(2,315 Views)
Highlighted

It's not a bug; a hyphen in an enum provides a list separator element in the control:

 

hyphen-list.png

 

hyphen-result.png

 

From the help: http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/adding_items_to_enumerated/

 

---
CLA
Message 3 of 11
(2,304 Views)
Highlighted
Solution
Accepted by topic author Blokk

Incidentally, you can use another type of dash:

 

- results in a divider

– results in – being displayed

 

You can produce it by holding ALT and typing 0150 on the numeric keypad.

---
CLA
Message 4 of 11
(2,292 Views)
Highlighted

@thoult wrote:

Incidentally, you can use another type of dash:

 

- results in a divider

– results in – being displayed

 

You can produce it by holding ALT and typing 0150 on the numeric keypad.


Good catch and a Nice suggestion. 

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 11
(2,285 Views)
Highlighted

thanks!

By the way, when we use a "-", so it will result in a line devider, it takes a number, yes?

So for example we have these items:

"A" (0), "B" (1), "-" (2), "C" (3)

In this case, the devider picks number 2, which is not really good when we programm: if we want to iterate the items (A,B,C), we have to pick numbers: 0, 1, 3. It makes for loops, etc. more complicated.

So why the devider "takes" away a number? It is not really usefull....

 

EDIT: i guess the point is that, even the devider is choosable, so it needs a separate item number...?

0 Kudos
Message 6 of 11
(2,272 Views)
Highlighted

This is indeed one problem of several with the use of separators in such controls, but:

 

- If you must have multiple separators in a control, use a Text Ring. Head to Edit Items for the control, then untick Sequential values. You can reorder the items but keep their values in the order you want. For instance, you could have:

 

A 0

B 1

C 2

D 3

- 10

E 4

F 5

G 6

- 11

H 7

I 8

 

etc, and you'll end up with a drop down with multiple selectors. It's a little unwieldy though.

 

- If you want to iterate through a text ring like the one above, you could just limit the number of iterations to the last item before your separator values start, e.g. 9.

 

- Enums allow a lot more flexibility, as you can put things in in whatever order you wish and then select (e.g. cases in a case structure) by name, rather than by number. Much more readable, and you can deal with the separator selection with a default case (or specifically a hyphen case, in which you do nothing!). If you want to iterate through elements of the enum, create a 1D array of enum constants, selecting which entry to use at each iteration, then pass to an autoindexing for loop.

 

- Whatever you do, make sure you type def the control!

---
CLA
Message 7 of 11
(2,254 Views)
Highlighted

good idea, thanks!

0 Kudos
Message 8 of 11
(2,252 Views)
Highlighted

Yeah, The items editor has a few restrictions that the Enum, Ring and Combobox properties do not have.... a small failure of the items editor and IMHO a good reason to overhaul the editor

"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 11
(2,218 Views)
Highlighted

@thoult wrote:

Incidentally, you can use another type of dash:

 

- results in a divider

– results in – being displayed

 

You can produce it by holding ALT and typing 0150 on the numeric keypad.


Actually, to be absolutely correct, a hyphen by itself is interpretted as a divider. A hyphen contained in a longer string works perfectly fine.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 11
(2,211 Views)