08-30-2017 10:35 AM
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
Solved! Go to Solution.
08-30-2017 10:46 AM - edited 08-30-2017 10:53 AM
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.
08-30-2017 11:46 AM
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) …
08-30-2017 11:47 AM - edited 08-30-2017 11:54 AM
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 😉