Start a new topic

single 3 state button push

hi there

can anyone help me I'm tying to us a single button to display 1 and after the next push to display 2 and the next 3 and them back to 1.

any idea how i can do this?


i did come up with this but only works for the first cycle:

if(t13.txt=="3")

{

 t13.txt=t13.txt-4

 t13.txt=t13.txt +"1"

}


if(t13.txt=="2")

{

 t13.txt=t13.txt-4

 t13.txt=t13.txt +"3"

}


if(t13.txt=="1")

{

 t13.txt=t13.txt-4

 t13.txt=t13.txt +"2"

}


Thanks Joe

1 Comment

place a Variable Component va0 on your page

then you code can be:


va0.val=va0.val+1%3

if(va0.val==0)

{

  t13.txt="1"

}

if(va0.val==1)

{

  t13.txt="2"

}

if(va0.val==2)

{

  t13.txt="3"

}


The first line va0.val=val0.val+1%3

- this  will add 1 to the current va0 value and if 3 or more will yield the remainder of va0.val / 3

Your valid values of va0.val are then 0,1,2,0,1,2,0,1,2,0,1,2,0 ...

on 0 display 1, on 1 display 2 and on 2 display 3


The % modulo sign means remainder, the returned values will start at 0 and not reach the divisor.


1 person likes this
Login or Signup to post a comment