FACER Community

Using VAR Decrement and VAR Increment Issue

Hi I’m having ago at giving users option to switch between Health data and Date and Time.

I ended up making two sections using VAR1 and VAR2 , I really want to use just one element, but first I would like the code changes to stop it from doing nothing if I click the right arrow more then once and the left arrow more then once. I think its just adding up the VARs but it should just go to the next element and back again so a max of 1 per click if that makes sense.

So in the image below im using.

Date = $#VAR_2#==0?100:0$
Time = $#VAR_2#==0?0:100$

Steps =$#VAR_1#==0?0:100$
Heart = $#VAR_1#==0?100:0$

1 Like

If you have only two states to switch between, I would rather use the VAR Toggle instead of incement/decrement. That would either make the variable into 0 or 1, that is easy to translate into show one or the other.

If there are N options to cycle trough, I would simply let the VAR to increment or decrement infinitely, and use modulo %N to pick when to show.


Thanks for the reply @petruuccios .

I changed to VAR toggle works much better and I can just click one to the next which I like.
So if I say had STEP HEAR DISTANCE CALORIES i.e 4 what would the logic look like to move to 4 instead of just 2 ?

If you want 4 options, you are going to need increment. You can still make it with 1 button though, using modular.
In each of the layers you can use an expression in the opacity field:

So basically:
$#VAR_1#%X==Y?100:0$ where X is the number of options and Y is 0 to X-1 for each options opacity field


Thank you so much for your time and reply working great :slight_smile:

1 Like