# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Enum to array of Booleans

Hi everyone!

I am looking for a "better" way of doing the following:

I have an enum with "ALL" as 0th value, and a number of testcases to choose from.

Now i need the enum represented as an array of booleans and each index corresponds to the i-th enum entry (for i > 0).

If "ALL" is selected all booleans in the array must be true,

for any other selection, only the corresponding array index should be true.

would love to get some suggestions.

thx and regards jwscs

If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 1 of 4
(3,332 Views)
Solution
Accepted by topic author jwscs

## Re: Enum to array of Booleans

Looks pretty clean, however since you want an array at the end, I would use "array subset" instead of the "index array".

Of course you could just use a 2D array diagram constant as a lookup table and index into it using the enum. That's what I probably would do.

Message 2 of 4
(3,315 Views)

## Re: Enum to array of Booleans

The lookup table is also more flexible for more complicated scenarios where code would be complicated.

Imagine an enum with the following states:

(1) all

(2) none

(3) A&B

(4) C&E

(5) A&E

(6) …

Message 3 of 4
(3,279 Views)

## Re: Enum to array of Booleans

hi altenbach!

thx for the suggestion, the lookup table is a neat idea.

and regarding the index-array-function, that is the end before each boolean value goes into a case-structure.

:cheers:

p.s.: i will mark as solved, but guys (and girls, and any sex u may feel like) feel free to come up with other ideas, which i'll then mark as solution too 😉

EDIT: gender stuff 😉

If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 4 of 4
(3,278 Views)