Reset value off app variable

I have Screens with alot of variables,
is there an easy way to reset the value of all of the variables used in one screen if screen opens?

I have found anything I would can easy when trying to manage (hundreds of) global variables. Here are a few strategies I have used:

  1. Build a reset function that resets everything. Not great, but a least it is all in one place.
  2. ALWAYS initialize variables at the start of an event or function. The only thing you know about thunkable variables is that they are dirty.
  3. Use invisible labels as variables. Rather than use actual variables, use screen components stored in a non-visible column. You can then set up a for each loop within the column and reset them. It also has the advantage as working like a watch window so you can see the state of the system at any given point.

Again, none of these are easy or good, but I’ve tried them…

Hmm… that invisible label trick is an interesting one. That allows you to use Any Component blocks, I presume?

Any time you find yourself using large numbers of variables, that usually is a red flag that you should be using a spreadsheet so that you can loop through the cells quickly and efficiently. But looping through spreadsheets in Thunkable seems to have its own challenges.

Queue @drted saying “You could loop through JSON…” :wink:

1 Like

Hello, thak you for your sugestions, but since I allready have these millions of variables I would like to keep them if possible and not try a different solution to store the values temporary.

Now I thought about making a pre screen to just reset all the values inside the app variables,
but somehow it is not working.

When you say it’s not working… what does that mean? Are none of those values resetting?

What proof do you have that the “pre screen” ran its blocks? For example, did you change the value of a label so you can visually see the change? Is the pre screen first in the list of screens and if not, how are you navigating to it?

While having duplicate value blocks for each variable might not cause problems, it’s inefficient. You only need the When Screen Opens block and I would disable the When Screen Starts block for now.