# \[Solved\] How to initialise many variables (in a loop)

**URL:** <https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264>\
**Category:** Questions about Thunkable X\
**Created:** [January 18, 2021, 5:06pm UTC](https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264 "2021-01-18T17:06:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jul.roy1311q9](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jul.roy1311q9](https://community.thunkable.com/u/jul.roy1311q9)\
**Post date:** [January 18, 2021, 5:06pm UTC](https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264/1 "2021-01-18T17:06:03Z")

</div>

Hi,

I have many buttons in my screen. I would like to be able to save their colors in “stored variables”.

Instead of having to manually create 1 variable block for each button, is there a way to do something like:

for button\_i in all buttons of myApp:  
initialize (stored) variable, name=button\_i\_color

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [January 18, 2021, 5:24pm UTC](https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264/2 "2021-01-18T17:24:29Z")

</div>

You should be able to do this with the blocks under the Any Component tab.

Something like this should fit the bill:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/5/756211927e17034c019f3bc49e4d80870e9ae9f5.png)

---

<div class="post-metadata">

**Author:** ![jul.roy1311q9](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jul.roy1311q9](https://community.thunkable.com/u/jul.roy1311q9)\
**Post date:** [January 18, 2021, 6:34pm UTC](https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264/3 "2021-01-18T18:34:04Z")

</div>

Oh thanks this is exactly what I needed!

It allowed me to make my code much more compact and scalable, now I could have a large amount of buttons and keep the same code 🙂

**BEFORE:**

 ![buttons](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/8/3834ecd048d9b4208ab8abd637a634a8255632c4.png)

**AFTER:**

 ![buttons_scalable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/e/1e083f42d7d166775a90cd45411c4ea3c51b064f.png)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:30pm UTC](https://community.thunkable.com/t/solved-how-to-initialise-many-variables-in-a-loop/1056264/4 "2024-11-08T13:30:42Z")

</div>


