# Variable type error issues and problems with the automagical approach to types

**URL:** <https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420>\
**Category:** Questions about Thunkable X\
**Created:** [October 26, 2020, 5:15pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420 "2020-10-26T17:15:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![keiferwq](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@keiferwq](https://community.thunkable.com/u/keiferwq)\
**Post date:** [October 26, 2020, 5:15pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/1 "2020-10-26T17:15:50Z")

</div>

There’s definitely some automagical stuff going on around variable types, but there are also situations where the need for to\_int or to\_string type functions would be useful, especially around APIs.

Specific example. The MAP component insists on lat and lon as numbers. It will fall on it’s face if you give it strings…

… BUT lat and lon are often treated as strings, so if you pull a lat and lon from an API there’s a good chance you end up with a string.

So the life of a variable initilized for lat could be:  
initialize lat = 0 (numeric)  
hit api lat becomes “40.123456” (type converts to string)  
hit map with lat = “40.123456” and it falls over (creating a thunkable app crash)

The workaround I’ve found is to use Math.

“40.123456” + 0 = 40.123456 (converts string to number)

Keifer

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [October 26, 2020, 5:27pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/2 "2020-10-26T17:27:03Z")

</div>

That is the work around I use for converting text to numbers. For numbers to text, use the JOIN block with just one element (the number).

---

<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:** [October 26, 2020, 7:27pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/3 "2020-10-26T19:27:34Z")

</div>

I agree those would be handy. It’s easy enough to make your own converter function(s), though, until we have built-in ones.

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [October 26, 2020, 8:02pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/4 "2020-10-26T20:02:50Z")

</div>

OR blocks like map make implicit conversions for us. Just saying…

---

<div class="post-metadata">

**Author:** ![keiferwq](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@keiferwq](https://community.thunkable.com/u/keiferwq)\
**Post date:** [October 26, 2020, 8:04pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/5 "2020-10-26T20:04:13Z")

</div>

Can you say that in a different way? I don’t understand.

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:** [October 26, 2020, 8:34pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/6 "2020-10-26T20:34:25Z")

</div>

> [@drted](#):
>
> OR blocks like map make implicit conversions for us. Just saying…

That actually makes a lot more sense! There’s no reason to send a string to a map component for a lat/lon value. So if you sent it the string “40.123456” it would just convert it to the number 40.123456 and use that for the lat/lon input value. If you sent it the string “hello” it would return an error.

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [October 26, 2020, 10:13pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/7 "2020-10-26T22:13:32Z")

</div>

There’s a Thunkable Use Case if I have ever read one. 😉

---

<div class="post-metadata">

**Author:** ![keiferwq](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@keiferwq](https://community.thunkable.com/u/keiferwq)\
**Post date:** [October 26, 2020, 10:36pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/8 "2020-10-26T22:36:25Z")

</div>

Nope. If you send it a string, even though that string contains an integer the map component blows up.

---

<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:** [October 26, 2020, 10:43pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/9 "2020-10-26T22:43:24Z")

</div>

@keiferwq We were talking about what we _wish_ Thunkable could do. Not what it can do right now.

For now, you have to convert the string to a number by adding 0 to it.

---

<div class="post-metadata">

**Author:** ![keiferwq](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@keiferwq](https://community.thunkable.com/u/keiferwq)\
**Post date:** [October 27, 2020, 3:12pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/10 "2020-10-27T15:12:40Z")

</div>

Oh… I see. Agreed.

---

<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:21pm UTC](https://community.thunkable.com/t/variable-type-error-issues-and-problems-with-the-automagical-approach-to-types/931420/11 "2024-11-08T12:21:55Z")

</div>


