# More than boolean Case Structure...

Hello team, iv’e noticed that i can or even need to use the case structure feature in more powerful way than true or false…
my need, is to use different kind of buttons to enter different kind of cases, since that every button return true\false value,im looing for way to navigate different taping to different cases,
Every help will warmly blessed
Nimrod Beker, Thunder-Bolts.

If your cases can be more easily separated into a bunch of numbers (Case 1, Case 2, Case 99) just create an enum or ring control with all of your cases listed in it and use that instead of a bunch of buttons.

If you’re set on using a bunch of buttons to create a sort of binary tree, (Red/Blue Alliance, Turn Left/Right, etc.), then you could put all of your button outputs into a boolean array and use the “convert boolean array to number” function to get the integer equivalent of the binary number represented by your button states. You’d have to keep track yourself of which state number means what, however.

Well first of all, great thanks kevin for trying to help.
I didnt really understood what should i do…
your idea sound very well, but one problem, buttons are boolean (by the way i could not find the “boolean array” over labview, so please, if you can to write where it is ) and as they are boolean, they’re value will equal, so it will not be able to recognize which button pressed, plz correct me if i made a mistake…
i need a thing that some-how know to work like if\else in C’s different languages.
something that work like this
“button 1 has been press so ill enter case 5. now button 3 and 7 pressed together, this would enter to case 4”
ill hope my little example will help you to help me better:)
Great thanks for you kevin and for every one that can help me to solve my desire lol
Nimrod Beker, Programming Team, Thunder-Bolts.

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?

I think I can explain it…if not then this is how I did it

There is a box in LabView that is called Joystick.Get. From there wire a “unbundle by name” to the button output. Then from there make the unbundle by name box the right size (i.e. shows 3 buttons if you want 3 of them) and then click each one and select the button you want from the dropdown menu. Make a Boolean to array box, and wire each button into a separate input (resize as needed). Then wire the output of that into a case statement.

now the boolean to array converts trues and falses into binary numbers.

example
…______
Button 1------|…| CASE STRUCTURE
Button 5------|…|------?]
Button 3------|_____|

if button one is pressed, then the output of the boolean to array will be 1
if button 5 is pressed then 2
if button 3 then 4
if one AND five then 3
etc.

So you have a 0, Default (should be made automatically) for nothing pressed or for some value that isnt specified…(in example if 5 and 3 pressed or 1 and 3 pressed)

and then the rest of them you stick in the number you want. so

CASE STRUCTURE
<|0,Default|>
<|1 |> button 1 pressed
<|2 |> button 5 pressed
<|3 |> button 1 and 5 pressed
<|4 |> button 3 pressed

note: all button numbers represent those on the joysticks included in the kit…trigger being button 1

if I have misnamed anything, I am sorry cause im in school right now and I dont have labview open to check the names.

Wow thanks, if think that what ive looking for :P…
ill try it later in the robot class…
i think this would solve it but keep generate ideas

As Kevin suggested, you can also have a control with more than just on/off.

If you can set this up as a list of options rather than a number of buttons, create a ring or enum control and wire it to the case structure. Fill the control with all the possible cases, and you can create a case in the case structure for each choice in the enum/ring control.