Anybutton click issue

Hello! So i have 4 static buttons on a screen and then multiple cloned buttons.

I use the 4 static buttons for navigating and or setting a variable value.

I am trying to exclude the 4 static buttons from my "all button’ command but they don’t seem to be excluded for some reason. I’m wondering if someone can help me with my blocks here.

I’m not convinced that your Button 12 or Button 14 or button.setChild block does what you think it should.

In programming, an OR operator is not the same as it would be in English. So a bowl of fruit with “not apples or oranges or bananas” (pardon the awkward phrasing) would generally mean that the bowl of fruit doesn’t have any apples, oranges nor bananas. But a compiler is going to treat those are logical values and compare them to “true”: is either apple or orange true? What does that even mean?

So in this case, I think it’s being interpreted as a logical expression: “Button 12 or Button 14” which … well, I don’t know how that gets valued but it ends up as either true or false. Then that value gets OR’ed with button.setChild and again, you end up with either true or false. Since 1 and 0 are generally equivalent to true and false, it’s highly likely that the component # you end up with is 1 or 0.

Instead, I would recommend that you make a list with the buttons you want excluded. Then, in the else if block, you would check to see does list contain [component]. There are multiple ways to get “does not” – you could put a NOT block in front of that or you could check if it’s equal to false.

Thanks @tatiang, you are right. Sometimes its hard for me to remember these types of things. Thank you for the reminder!!

i got it. thank you! i got it as you typed it up

2 Likes

Great! You’re welcome.

1 Like