Showing results for 
Search instead for 
Did you mean: 

multivariate case

Go to solution

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 18

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

0 Kudos
Message 12 of 18

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
0 Kudos
Message 13 of 18

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

0 Kudos
Message 14 of 18

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 🙂

Honestly, do NOT do it like this!
0 Kudos
Message 15 of 18

You may want to look at this idea.

0 Kudos
Message 16 of 18

One more: Array lookup


Message 17 of 18

@GregSands wrote:

One more: Array lookup


Beautiful one!

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 18 of 18