LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multivariate case

Solved!
Go to solution

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

Capture.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 18
(1,370 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 12 of 18
(1,366 Views)

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
(1,355 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 14 of 18
(1,345 Views)

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

1. Nested Case Structures (as Lynn suggested above)

FlagNested.png

 

2. Obfuscated code

FlagOb.png

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

Spoiler
Honestly, do NOT do it like this!
0 Kudos
Message 15 of 18
(1,316 Views)

You may want to look at this idea.

0 Kudos
Message 16 of 18
(1,308 Views)

One more: Array lookup

FlagArray.png

Message 17 of 18
(1,304 Views)

@GregSands wrote:

One more: Array lookup

FlagArray.png


Beautiful one!

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 18 of 18
(1,285 Views)