11-17-2010 02:25 PM - edited 11-17-2010 02:26 PM
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.
Solved! Go to Solution.
11-17-2010 02:31 PM
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.
11-17-2010 02:56 PM
I never knew what "implies" actually did! There is a use out there for it!
11-17-2010 03:05 PM
You could do it like this too. When the number is zero then both are false other wise they will be 2 or 3.
11-17-2010 03:08 PM
I am sure there are others
11-17-2010 03:10 PM
@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:
11-18-2010 05:32 AM - edited 11-18-2010 05:38 AM
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.
11-18-2010 01:07 PM
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.
11-18-2010 01:50 PM
@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.
11-19-2010 04:04 AM
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.