# Type errors with variables (mixing string / int) resulted in a blank screen

**URL:** <https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942>\
**Category:** Feedback\
**Created:** [September 16, 2020, 6:11am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942 "2020-09-16T06:11:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![natasha.sitskyw](https://avatars.discourse-cdn.com/v4/letter/n/57b2e6/32.png) [@natasha.sitskyw](https://community.thunkable.com/u/natasha.sitskyw)\
**Post date:** [September 16, 2020, 6:11am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/1 "2020-09-16T06:11:38Z")

</div>

Hi,

I had a program where there was a variable that was expected to be a string throughout the code. I made a mistake where in some part of the program it was set to an int rather than a string and this resulted in a blank screen (the whole phone) when using live test from a Windows laptop using Chrome.

This was very difficult to track down. Can a type error be handled more elegantly?

FWIW… here is what the chrome dev tools showed… an error within thunkable’s code? There were two errors like this:

Uncaught TypeError: Reduce of empty array with no initial value  
at Array.reduce ()  
at Screen.eval (unknown:54)  
at yo (2.21b2f110.chunk.js:1)  
at vo (2.21b2f110.chunk.js:1)  
at qa (2.21b2f110.chunk.js:1)  
at ks (2.21b2f110.chunk.js:1)  
at mc (2.21b2f110.chunk.js:1)  
at fc (2.21b2f110.chunk.js:1)  
at oc (2.21b2f110.chunk.js:1)  
at 2.21b2f110.chunk.js:1

---

<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:** [September 16, 2020, 6:21am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/2 "2020-09-16T06:21:58Z")

</div>

Hi @natasha.sitskyw, welcome to the community! 👋

> [@natasha.sitskyw](#):
>
> I made a mistake where in some part of the program it was set to an int rather than a string

Thanks for reporting this - glad to hear you were able to find a solution.

Could you share a simple example (or even just a screenshot) that reproduces this issue with mis-typed variables?

Thanks

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [September 16, 2020, 6:22am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/3 "2020-09-16T06:22:02Z")

</div>

How did you initially set the variable to a string? And how/when did you set it to an integer? And why did it fail since it’s possible, for example, to display an integer as a string (in a Label). Were you doing string manipulations on the variable?

> [@natasha.sitskyw](#):
>
> Can a type error be handled more elegantly?

This would be helpful but I don’t know the answer.

---

<div class="post-metadata">

**Author:** ![natasha.sitskyw](https://avatars.discourse-cdn.com/v4/letter/n/57b2e6/32.png) [@natasha.sitskyw](https://community.thunkable.com/u/natasha.sitskyw)\
**Post date:** [September 16, 2020, 7:10am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/4 "2020-09-16T07:10:55Z")

</div>

The variable was initialised using an “initialize” block as a string.

The variable was set to an integer within a “when game opens” block.

The variable was manipulated using string operations within a “when button was clicked”.

The white screen happened when the button was clicked. Presumably this was because the variable was changed to an integer type and then it was attempted to be manipulated as a string type.

---

<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:** [September 16, 2020, 7:18am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/5 "2020-09-16T07:18:40Z")

</div>

> [@natasha.sitskyw](#):
>
> The variable was set to an integer within a “when game opens” block.

So…the solution was to put the number is a string block? Or did you do something else?

> [@natasha.sitskyw](#):
>
> The variable was manipulated using string operations

What string operations did you need to do on an int?

---

<div class="post-metadata">

**Author:** ![natasha.sitskyw](https://avatars.discourse-cdn.com/v4/letter/n/57b2e6/32.png) [@natasha.sitskyw](https://community.thunkable.com/u/natasha.sitskyw)\
**Post date:** [September 16, 2020, 7:20am UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/6 "2020-09-16T07:20:55Z")

</div>

The problem was simply that string manipulations were done on a variable that was (accidentally) set to an int - a type mismatch. Once this was corrected (the variable always set as a string) the program worked fine.

Thunkable should be able to handle type errors more elegantly with a error message rather than a “blank screen”… I would hope. As it took some time to track this error down.

---

<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, 12:24pm UTC](https://community.thunkable.com/t/type-errors-with-variables-mixing-string-int-resulted-in-a-blank-screen/820942/7 "2024-11-08T12:24:00Z")

</div>


