LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestion for turning this into one case structure

Solved!
Go to solution

This is a snippet from some exisiting code we were hired to modify/clean up. I have to assume there is some way I can reduce this to only have one case structure, maybe with a not-and or not-or. Or maybe I'm overthinking this. Basically I keep confusing myself in relatively simple code when thinking about the booleans being compared. Any help is appreciated.

 

0 Kudos
Message 1 of 10
(3,639 Views)

When you want something to happen when only 1 of the 4 boolean combinations happens (in your case, you want the global to *not* be written in that 1 combination), you should use Implies.

Message 2 of 10
(3,631 Views)

I never knew what "implies" actually did! There is a use out there for it!

0 Kudos
Message 3 of 10
(3,615 Views)

You could do it like this too. When the number is zero then both are false other wise they will be 2 or 3.

 

Example_VI_BD.png

Tim
GHSP
0 Kudos
Message 4 of 10
(3,603 Views)

I am sure there are others

 

Untitled.png

Omar
0 Kudos
Message 5 of 10
(3,598 Views)

 


@for(imstuck) wrote:

I never knew what "implies" actually did! There is a use out there for it!


 

I wrote a nugget about Implies back in 2006.  As a reminder, here's the list of every nugget I've ever written:

 

Darren's Nuggets

0 Kudos
Message 6 of 10
(3,596 Views)
Solution
Accepted by topic author GregFreeman

This does look to be just a NAND, pure and simple.

The truth table I came up with was:

 

old   new    write to global

0      0         1 (< is false, new is false)

0      1         1 (< is true)

1      0         1 (< is false, new is false)

1      1         0 (< is false, new is true)

 

Classic not-and.

Message 7 of 10
(3,522 Views)

Of course if this were implemented:

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-Multiple-Case-Selectors/idi-p/1301780

 

you would just wire the two booleans to a single case structure and specify the cases directly without resorting to Boolean logic.

0 Kudos
Message 8 of 10
(3,474 Views)

 


@KathrynB wrote:

This does look to be just a NAND, pure and simple.

The truth table I came up with was:

 

old   new    write to global

0      0         1 (< is false, new is false)

0      1         1 (< is true)

1      0         1 (< is false, new is false)

1      1         0 (< is false, new is true)

 

Classic not-and.


Your logic works in the case where you want one result if both inputs are TRUE, and another result otherwise.  That would require modifying the original logic.  In the case where the original logic persists, then you need one result if one input is TRUE and the other is FALSE, and another result otherwise.  In this case, you need Implies.

 

0 Kudos
Message 9 of 10
(3,467 Views)

Implies works for this, but it is as simple as a NAND which is a lot easier than the implied logic of Not-A Or B

 

The less than gives you

 

A     B       A<B

F     F        F

F     T        T

T     F        F

T     T        F

 

The other logic requirement given is that B is False to write to the global, which alters the above table to the one I quoted originally. The original logic hasn't been modified, just looked at as logicals rather than numbers, and more people will immediatly follow a NAND than an implies.

0 Kudos
Message 10 of 10
(3,425 Views)