View Single Post
  #3   Spotlight this post!  
Unread 13-01-2009, 09:28
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: More than boolean Case Structure...

There are a couple ways of transitioning from a set of Booleans to logic decisions.

First, you can nest lots and lots of cases. LV doesn't have if/elses, but a Boolean case is pretty similar. Honestly, this is the hardest to read or modify, but it is an option.

Second, you can make an array of Booleans. Because the buttons are initially returned in a cluster, you can easily convert them to an array. Go either the array of cluster palette on the diagram, and there will be a bullet shaped node with [] and a vertical set of boxes.

If you only care about one button, many people will simply search the array for True, then switch on the numeric index returned from search. -1 means no bottons, 0 means at least first button pressed, etc.

If you care about combinations, most people will convert this array of Booleans to a number. It is in the Numeric>>Conversion palette. This will give you a 12 bit number storing all 4096 combinations. You can switch from the number and start filling in cases. You can add a new case diagram for some new code. You can then change the numbers that will activate that case by clicking on the text and typing into it. To run on multiple buttons, use either .. or ,s, for example [1, 4, 8] lists three independent numbers, [0..1024] is the short way of doing all numbers in between and including, and you can mix them too such as [0, 4..8]. Unfortunately, you cannot display the case in hex, so you will be doing the math conversions in your head, no problem right?

Greg McKaskle
Reply With Quote