# Reset all variables on a page (or at least button counts)

**URL:** <https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202>\
**Category:** Questions\
**Created:** [July 7, 2020, 7:10pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202 "2020-07-07T19:10:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Todd\_Feitelson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/todd_feitelson/32/898_2.png) [@Todd\_Feitelson](https://cl.desmos.com/u/Todd_Feitelson)\
**Post date:** [July 7, 2020, 7:10pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/1 "2020-07-07T19:10:03Z")

</div>

Hi. I’m wondering if there’s a way to have a button reset a page as if it were just arrived at. Alternately, can I set a button to reset the pressCount of a different button to zero? I can’t figure out if resetOnChange can do this. Thanks!

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 7, 2020, 7:55pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/2 "2020-07-07T19:55:57Z")

</div>

Well, if you’re just trying to use the pressCount for something. You could have a “reset” button capture the current pressCount. And have a variable for the effective pressCount as the difference between the actual pressCount and the pressCount when the reset was pressed.

```auto
capture("pCount"): buttonName.pressCount
effectivePressCount = numericValue("${buttonName.pressCount}-${resetButtonName.lastValue("pCount")}")

```

---

<div class="post-metadata">

**Author:** ![Todd\_Feitelson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/todd_feitelson/32/898_2.png) [@Todd\_Feitelson](https://cl.desmos.com/u/Todd_Feitelson)\
**Post date:** [July 7, 2020, 8:12pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/3 "2020-07-07T20:12:30Z")

</div>

Very clever! I’m not sure that works for me, though. I have four other buttons on the page, each of which I’m using as a three-way toggle (0, 1 or ?). They will all have been clicked a different number of times. I want a fifth button to reset them all to their initial states (which may also be different for each button.). Hmmm.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 7, 2020, 10:08pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/4 "2020-07-07T22:08:20Z")

</div>

Same process should work. You can have multiple captures for the same button.

```auto
capture("p0"): b0.pressCount
ePC0 = numericValue("${b0.pressCount}-${reset.lastValue("p0")}")
capture("p1"): b1.pressCount
ePC1 = numericValue("${b1.pressCount}-${reset.lastValue("p1")}")

```

---

<div class="post-metadata">

**Author:** ![Todd\_Feitelson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/todd_feitelson/32/898_2.png) [@Todd\_Feitelson](https://cl.desmos.com/u/Todd_Feitelson)\
**Post date:** [July 7, 2020, 11:01pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/5 "2020-07-07T23:01:46Z")

</div>

Excellent. I think this clicked for me now. Thanks!

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 8:06am UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/6 "2023-02-25T08:06:02Z")

</div>

Can you please clarify how this works?  
If this is the code for a separate “reset” button, how would buttons “b0” and “b1” know that they have to change their effective changeCount?  
Thank you.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 25, 2023, 2:39pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/7 "2023-02-25T14:39:01Z")

</div>

The effective counts are created in the reset button’s CL, but variables in any component can be referenced by other components if needed.

```auto
myVar= componentName.script.refVarName

```

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 5:56pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/8 "2023-02-25T17:56:27Z")

</div>

So how will it look for button’s b0 CL pressCount?

Edit the Computation Layer Script for b0

```auto
hidden: this.pressCount > 0
pressCount = reset.script.effectivePressCount #this doesn't seem to work

```

Edit the Computation Layer Script for reset

```auto
capture("pCount"): b0.pressCount
effectivePressCount = numericValue("${b0.pressCount}-${reset.lastValue("pCount")}")

```

Button b0 has many functions, and I need it to be reset after all procedures are completed so that the cycle could be repeated as many times as needed.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 25, 2023, 6:58pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/9 "2023-02-25T18:58:14Z")

</div>

“this.pressCount” references the actual pressCount of the component, not the pressCount variable you made. Remove “this.” and I think it should work the way you intend.

Probably better practice to not name variables the same as sinks or sources. For example, i know a lot of people make “correct” variables and confuse themselves trying to reference the “correct” sink at times they haven’t defined the variable. I prefer “check”.

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 7:31pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/10 "2023-02-25T19:31:55Z")

</div>

I tried this, and it didn’t work :((

Edit the Computation Layer Script for “test” button

```auto
hidden: pressCount > 0
pressCount = reset.script.effectivePressCount  

```

Edit the Computation Layer Script for “reset” button

```auto
hidden: test.pressCount = 0
capture("pCount"): test.pressCount
effectivePressCount = numericValue("${test.pressCount}-${reset.lastValue("pCount")}")

```

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 25, 2023, 8:05pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/11 "2023-02-25T20:05:42Z")

</div>

Is your desired behavior that

1. The reset button is only hidden before the rest button is pressed, and continues to remain visible thereafter.
2. The test button hides when pressed and reappaears when reset is pressed.

If so, easier might be for “reset” CL:

```auto
hidden: test.pressCount>0

```

… and for “test” CL:

```auto
hidden: this.pressCount>reset.pressCount

```

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 8:59pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/12 "2023-02-25T20:59:21Z")

</div>

Well, it’s not what I need.  
I need an action button that allows to perform several actions. After all is over, I need a reset button to reset the action button to its original state.

Big thank you for your time and effort to help.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 25, 2023, 10:47pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/13 "2023-02-25T22:47:51Z")

</div>

Can you use clickable buttons on a graph instead of action buttons? They are much easier to use and do resets and such.

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 10:57pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/14 "2023-02-25T22:57:38Z")

</div>

How do you do that? I would appreciate a more detailed instruction because I am a rookie.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 25, 2023, 11:24pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/15 "2023-02-25T23:24:19Z")

</div>

Sure. But can you explain more what you want it to do? I can’t really tell from your previous post. Making a reset is not a problem but I’m not clear what it means for one button to do multiple actions.

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 25, 2023, 11:29pm UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/16 "2023-02-25T23:29:33Z")

</div>

Gladly. For example,

Action 1. Show graph with the initial bounds (-10,10,-10,10). Students will be able to set new bounds with a Zoom Box.  
Action 2. Zoom In. Students explore the graph within the new bounds.

RESET. Show the graph with the initial bounds and ready to repeat Action 2.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 26, 2023, 12:34am UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/17 "2023-02-26T00:34:10Z")

</div>

Ok, here is an example: [graph with zoom • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/63fa9c456ae67fb387c6d0dc)

There are actions in Desmos which are created using an arrow -\>. You can use these to set the value of a variable. So you can make an action, and assign it a name, like a\_ction1 = n → n + 1 , which would increase n by 1. You then make an object clickable (it can be a point, a polygon, a graph, whatever) and then type a\_ction1 in the click field. When you click, it will then run that action.

In this case, since you want an alternating on/off thing, I used modulo 2. So basically just keep increasing the number of presses, but then create a conditional that sets it to 1 or 0 depending on the value mod 2.

Let me know if you have any questions or if you need a different example.

---

<div class="post-metadata">

**Author:** ![Alexander\_3691](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/alexander_3691/32/3959_2.png) [@Alexander\_3691](https://cl.desmos.com/u/Alexander_3691)\
**Post date:** [February 26, 2023, 1:48am UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/18 "2023-02-26T01:48:11Z")

</div>

This is what I actually have in mind. Please have a look. I do not know how to return the page to its original condition.

[Rounding Calculator](https://teacher.desmos.com/activitybuilder/custom/63fab9781cdebef6adeba40b)

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 26, 2023, 7:49am UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/19 "2023-02-26T07:49:13Z")

</div>

Ok, take a look now. I combined everything into 1 graph on the left, using conditionals. And on the right, I made a single button that cycles through the action number. [graph with zoom • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/63fa9c456ae67fb387c6d0dc)

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [February 26, 2023, 7:51am UTC](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202/20 "2023-02-26T07:51:15Z")

</div>

Also, you may be interested in this activity: [Multiple Zooming Number Lines (clickable version) • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/62999af84920630519c93b48)

[Next page](https://cl.desmos.com/t/reset-all-variables-on-a-page-or-at-least-button-counts/1202.md?page=2)
