# Problem with initialize variable!

**URL:** <https://community.thunkable.com/t/problem-with-initialize-variable/582206>\
**Category:** Questions about Thunkable X\
**Created:** [May 21, 2020, 11:11am UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206 "2020-05-21T11:11:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![altsoftcode](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/altsoftcode/32/62708_2.png) [@altsoftcode](https://community.thunkable.com/u/altsoftcode)\
**Post date:** [May 21, 2020, 11:11am UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206/1 "2020-05-21T11:11:34Z")

</div>

I am having problems when initialize a variable setting value.

I set the variable with “initialize app variable” and set the value.  
Then when i do “when screen starts” i try to use the variable and is undefined!!!

Everything was working. I already have an APP created from the same project.  
But today i was going to test and there was an error, thats when i discover that the error was that the variable was undefined…and it happened without a reason!

Anyone with the same problem?

Please help me.

Thank you.

---

<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:** [May 21, 2020, 11:52am UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206/2 "2020-05-21T11:52:08Z")

</div>

> [@altsoftcode](#):
>
> Then when i do “when screen starts” i try to use the variable and is undefined!!!

Hey @altsoftcode - can you share a screenshot of the blocks you are using?

Have you considered using the logic blocks to handle what happens if the value from a variable is undefined?

---

<div class="post-metadata">

**Author:** ![altsoftcode](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/altsoftcode/32/62708_2.png) [@altsoftcode](https://community.thunkable.com/u/altsoftcode)\
**Post date:** [May 21, 2020, 12:00pm UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206/3 "2020-05-21T12:00:27Z")

</div>

Thank you @domhnallohanlon for your answer.

There is not much to share. It is a normal procedure as described here: [https://docs.thunkable.com/variables](https://docs.thunkable.com/variables)

I decided to create stored variables, cause it worked, but this means that i have to change everything i made until now.

I think it is a problem in thunkable. I tested in two devices and is the same problem.  
As i said everything was working great until today and i am talking about months of work.

If you want you can try to set an app variable and then when screen starts alert the value.

Thank you very much.

---

<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:** [May 21, 2020, 12:04pm UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206/4 "2020-05-21T12:04:38Z")

</div>

> [@altsoftcode](#):
>
> but this means that i have to change everything i made until now.

If you just change the variable type from `app` to `stored` then everything will be updated automatically. There are no other changes needed.

> [@altsoftcode](#):
>
> I think it is a problem in thunkable

It might be? If you share a screenshot thought you will help us establish whether it actually is or not.

Also,

> [@domhnallohanlon](#):
>
> Have you considered using the logic blocks to handle what happens if the value from a variable is undefined?

Thanks!

---

<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:29am UTC](https://community.thunkable.com/t/problem-with-initialize-variable/582206/5 "2024-11-08T11:29:06Z")

</div>


