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

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!

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.

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

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.

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

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

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