# Question regarding counter

Dec 08, 2016

Hi All,

So i have the following issue ...

I have  2 x 4 buttons that a user can press.
To make it more understandable see below

1. 2. 3. 4.
5. 6. 7. 8.

When a user clicks 1 or 2 variable 1 changes to true
When a user clicks 3 or 4 variable 1 changes to false
When a user clicks 5 or 6 variable 2 changes to true
When a user clicks 7 or 8 variable 2 changes to false.

Now i would like to count the amount of trues from these two variables.
It is possible to start with 5 - 8 and a user can change the buttons when he likes.

Now i would like to change a picture based on the amount of trues. if true once picture red. if true is twice picture blue. if true is 3 times picture green.

So there will be more buttons to achieve this but how do i count.

I was thinking of +add in a number variable but when a user clicks multiple times since he is alowed this wont work.

Kind regards!

###### 4 Replies

Sanne:

As far as I can tell, you don't really need to count the number of clicks, you only need to monitor the variable total. You do say that the user can click multiple times so it may not work but I'm not sure why. I would:

1. Create a number variable.
2. When the user clicks one of the buttons, add a 1 to the variable count.
3. When the user clicks one of the other buttons, subtract 1 from the variable count.
4. When the user clicks a button, add a trigger that evaluates the number. For example: If variable1 == 3 change picture to green. Be sure to place this trigger after you add the number to the variable.

I think that should work.

Here is a sample module that might help clear up some of your thinking.

I don't think it is what you want, because I'm not sure I understand everything.

I agree with Steve, I don't think you need to count the clicks. As I understand your post, you want to change the color based on the end results, not the process of arriving there.

I'm certain I don't understand how you can get 3 states of the picture based on the status of only two variables, but this sample may give you some ideas to get you started.

Remember, Steve and I are just guessing. If this doesn't help, add an attachment here of what you have, and someone can give you some help that may be useful.

Hi i have solved it myself. it would take me a while to explain but if anyone wants to know in the future then let me know and i can send u a example. it is more complex then u think since users can click anything that u want.

so regarding the +1 method. This will not work since 1 and 2 are equal in output and 3 and 4 have the same output aswell. Now lets say we do +1 when 1 or 2 are clicked and do nothing when 3 or 4 are clicked.. What wil happen if the user presses 1212121212 you wil get 10 in your variable. So i cant use it to make a decision on.

Kind regards and thank you for thinking with me.

Regards,

Dennis

Thanks for popping in with an update Sanne. Glad you were able to get it working for you :)