# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Re: multivariate case

Thats what "Boolean to 0 1" and "Boolean Array to Number" are for 😉

"Should be" isn't "Is" -Jay
Message 11 of 18
(909 Views)

## Re: multivariate case

I like LabVIEW a lot, but this is one of the areas where the text code solution is more straightforward and readable than most LabVIEW solutions. You might think GreyGrey's suggestion isn't elegant, but most alternatives are likely to be considerably worse.

The main exception I can think of is to "cheat" and use a LabVIEW formula node that accepts a limited syntax of text code.

P.S.  Started the answer above, called pulled away, returning hours later.  Jeff B's solution is essentially similar to the one described by GreyGrey.  Either is a fairly readable solution to your very specific problem.  GreyGrey's string-based solution would extend more naturally to a large number of variables.  But both very much depend on the fact that all the logical operators are AND's.

For your specific problem full of nothing but AND's, both are fine.  For the much broader general situation, such approaches either won't work or will likely be a lot less readable.  Consider a case where you have to support logic including OR's or NOT's like:

((A && B) || (B && NOT(C)) || (D && (E || F)) )

You'd either string together a raw, literal implementation along the lines of the one Bob_Schor illustrated while recommending against, or you could use the Formula Node I mentioned before to preserve the relative readability of the text-based logic.

Not a critique of earlier replies which definitely addressed the question asked, just offering some additional thoughts since the original problem was a special case that just happened to lend itself to a more-elegant-than-normal pair of solutions.

-Kevin P

Message 12 of 18
(905 Views)

## Re: multivariate case

Kevin, the logic operators are handled by multiple value cases or case ranges.  The text solution is a bit more scaleable but,less readable.  Join numbers is limited to 64bits.  OTOH, if you have a 2^63-1 if else selections, you have much bigger problems😙

"Should be" isn't "Is" -Jay
Message 13 of 18
(894 Views)

## Re: multivariate case

To-MAY-to, To-MAH-to.  I'm just saying that to *me*, the text form of expressing those logical combinations seems much more straightforward and understandable at a glance than schemes that map those logical operations into ranges of magic numbers or involve deeply nested case structures or require a cascading series of various logic operators.  It's not that LabVIEW's *incapable*, just that I find it kinda awkward in some areas.  It all compiles just fine, but I think the LabVIEW syntax for moderately complex logic or math expressions is often inferior to text code.  Not that I'm gonna convert back.

-Kevin P

P.S.  Congrats to Cubs and fans, that's why I'm still up now

P.P.S.  For the record, I was actually rooting for Cleveland, but there's noone in the NL I'd rather they lose to

Message 14 of 18
(884 Views)

## Re: multivariate case

Just for completeness, here are a couple more ways to do this:

1. Nested Case Structures (as Lynn suggested above)

2. Obfuscated code

Who needs to know the mapping as long as you get the right answer 🙂

Spoiler
Honestly, do NOT do it like this!
Message 15 of 18
(855 Views)

## Re: multivariate case

You may want to look at this idea.

Message 16 of 18
(847 Views)

## Re: multivariate case

One more: Array lookup

Message 17 of 18
(843 Views)

## Re: multivariate case

@GregSands wrote:

One more: Array lookup

Beautiful one!