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
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?
This would be helpful but I don’t know the answer.
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.
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.