# How to create additional local variables inside functions?

**URL:** <https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843>\
**Category:** Questions about Thunkable X\
**Created:** [October 26, 2019, 3:47pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843 "2019-10-26T15:47:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollke](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/rollke/32/14413_2.png) [@rollke](https://community.thunkable.com/u/rollke)\
**Post date:** [October 26, 2019, 3:47pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/1 "2019-10-26T15:47:55Z")

</div>

Hi,

due to the initialization of variable it is only possible to create app variables, and storage or cloud variables. All of them are global to the app.

But what, if I want to create local variables (e.g. help variables) inside a function. I do not mean the parameters, they are local. I mean additional local variables.

 ![28](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aabc8ceba8b7ff32e3fe741c689f8a2fe64111f8.png)

---

<div class="post-metadata">

**Author:** ![rollke](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/rollke/32/14413_2.png) [@rollke](https://community.thunkable.com/u/rollke)\
**Post date:** [October 27, 2019, 9:30am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/2 "2019-10-27T09:30:20Z")

</div>

Where is this block from Thunkable classic gone to x.thunkable?  
Or is there a workaround for x.thunkable?  
 ![44](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/2/7228ea96b22f15c92ddb18582747e98d7d0c373b.png)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 27, 2019, 10:17am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/3 "2019-10-27T10:17:58Z")

</div>

Hi,

I have long made the request for these blocks, but no information about when they will appear, or if they appear at all I do not have.

As a workaround, you can do this: call the function block parameters prefixed with \_ (as it was done in Javascript before the let declarations), and when the function set its value to undefined.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f8b1587dbb63eac7a8a7a3f2eac430afa1dbb77d.png)

---

<div class="post-metadata">

**Author:** ![rollke](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/rollke/32/14413_2.png) [@rollke](https://community.thunkable.com/u/rollke)\
**Post date:** [October 27, 2019, 3:46pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/4 "2019-10-27T15:46:57Z")

</div>

Thank you actech.  
But the problem is, that there is only the initialize app block for variable definition.  
When teaching this to students I cannot use a workaround like yours, because they cannot initialize local variables within the function block. But for teaching computer science in a class it is important to know the difference between local and global data.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 27, 2019, 5:35pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/5 "2019-10-27T17:35:36Z")

</div>

I agree with you. While using Thunkable X is not possible to show the local variables.

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [October 31, 2019, 8:17am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/6 "2019-10-31T08:17:52Z")

</div>

Hi Thunkers! 👋

Using a lot **`App Variables`** causes a lag 😕 Many of us have experienced it…  
So, can the Thunkable Team add a new variable type like **`local variable`** -

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/2/42aee6a3e5d3463ae954be800894f7f830c1bc0e.png)

When I need to use variables for only a block like -

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/01f9eec5ebbccb6ab581f65ef3279f199886e26e.png)  
I need to use ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/8/b8831507968c0c90a01c488657a7b6059ea1f9b6.png)

> Using **`App Variables`** causes a lag 😕 Many of us have experienced it…

I will be waiting 🙂  
**Thanks! 🎉**

**P.S.** This request was also made by @actech once in a post 👍

---

<div class="post-metadata">

**Author:** ![rollke](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/rollke/32/14413_2.png) [@rollke](https://community.thunkable.com/u/rollke)\
**Post date:** [October 31, 2019, 8:59am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/7 "2019-10-31T08:59:28Z")

</div>

That‘s exactly what I want, too (see my post some days ago)

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [October 31, 2019, 9:43am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/8 "2019-10-31T09:43:41Z")

</div>

Many Thunkers want it, there are various posts which say it.

Thanks! 😊

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [October 31, 2019, 12:40pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/9 "2019-10-31T12:40:13Z")

</div>

Thanks for the feedback @rollke, @kartik14 and @actech

We definitely want to keep improving the platform, but I’m not aware of any plans to add in local variables.

* * *

> [@rollke](#):
>
> I want to create local variables

@rollke is there anything that the current offering of variables does not allow you to do? i.e. is the lack of local variables preventing your from completing some important aspect of your app at the moment?

* * *

> [@rollke](#):
>
> But for teaching computer science in a class it is important to know the difference between local and global data.

ok - this is a fair point!

* * *

> [@kartik14](#):
>
> Using a lot **`App Variables`** causes a lag 😕 Many of us have experienced it…  
> So, can the Thunkable Team add a new variable type like **`local variable`** -

I think what you’re really asking for here @kartik14 is for faster variables, no? 😂

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [October 31, 2019, 2:19pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/10 "2019-10-31T14:19:02Z")

</div>

@domhnallohanlon,

you caught me! 😂 😅

Since App Variables make the Platform lag, I requested for local variables 😄  
If app variables can improve, there’s no need of local variables for me 😄

Thanks! 😊

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [October 31, 2019, 3:06pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/11 "2019-10-31T15:06:01Z")

</div>

Thanks for clarifying @kartik14.

As mentioned above, we’re keen to keep improving the platform but at this stage have to prioritise the features that are preventing users from completing their projects.

If the absence of a component/property is not blocking users from building their app then it gets added to the queue, but with a lower priority.

Hope that makes sense.

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [October 31, 2019, 3:26pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/12 "2019-10-31T15:26:16Z")

</div>

> [@domhnallohanlon](#):
>
> Hope that makes sense.

Yep, this makes complete sense, priorities first! 😊

Thanks for your time! 😊

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [November 17, 2019, 8:22am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/13 "2019-11-17T08:22:20Z")

</div>

Hi,

Imitation of a local variable. To create a local variable, you must create a function parameter with the same name as the variable block from the function parameter.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/a/5ab808664f107e2c6ff2e66451dde4234fe4761b.png)

---

<div class="post-metadata">

**Author:** ![rollke](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/rollke/32/14413_2.png) [@rollke](https://community.thunkable.com/u/rollke)\
**Post date:** [November 17, 2019, 9:03am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/14 "2019-11-17T09:03:33Z")

</div>

Thank you!

But would you really teach students to create and use local variables?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [November 17, 2019, 9:09am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/15 "2019-11-17T09:09:20Z")

</div>

No, the method I showed is called like this - turning a global variable from a parameter of function into a local variable. Unfortunately, this is the maximum that can be achieved from Thunkable X.

If student training is based on Thunkable X, then the teacher will often have to say that this or that mechanism of work is specific to the Thunkable X platform and in programming languages it works differently or there is no such concept at all.

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [November 19, 2019, 6:02pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/16 "2019-11-19T18:02:58Z")

</div>

> [@\[Solved\] Is there some reason why my blocks might start to lag?](http://community.thunkable.com/t/is-there-some-reason-why-my-blocks-might-start-to-lag/55876/152):
>
> Our latest release (from late yesterday) has a fix which should cause some improvement in lag for projects with large numbers of blocks. The improvement should occur when moving, modifying, adding and deleting blocks. The improvement may be significant for some projects and marginal for others. Let us know if you notice any change. We have also started to make some more changes which, when complete, should further improve lagginess with large numbers of blocks and screens. This work is like…

---

<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, 11:46am UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/17 "2024-11-08T11:46:38Z")

</div>



---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [December 19, 2024, 5:02pm UTC](https://community.thunkable.com/t/how-to-create-additional-local-variables-inside-functions/289843/18 "2024-12-19T17:02:34Z")

</div>


