How do I check if my program is Run for the First Time?

I have an app with several screens. The latter screens save variables to the local storage. When the last screen loops back to the first screen it load the variables fine.

If there are no variables saved which will only happen on the 1st run, then I would like to store default values. Right now, I depend on loading the variables from local storage and if there are none, then my screen won’t display properly until the user navigates once around through all the screens.

It seems necessary, that I have to download the app first before I can test these functions and I am also wondering if the new installation uses the previous install’s local storage or are they completely deleted when I uninstall the previous attempt and download again?

Set something like :

If variable = null then do …

Should work

Actually, I think there is some kind of bug in Thunkable. I did some tests and get funny results. Maybe the Thunkable developers can have a look at it?

Test1:
test1

Label1 shows “null”, which I would expect, since var1_key does not exist in local storage

Test2:
test2
Here I would expect that Label1 shows “Default for variable 1”, but this is not the case. Label1 shows “null” again.

Test3:
test3
Here the label shows “NOT null”

To me it seems that testing for null doesn’t work. The first two tests show that apparently null is returned if the key does not exist in local storage. However, testing for null does not work.
(BTW, I also tried it the other way around, so test for value=null, and swapping the do and else parts. Same result)

Regards Rob

Hi Rob,

The “null” block has an object type, which makes it difficult to compare with it. For the correct comparison with the string “null”, the null block must be cast to a string type, adding it via “join”.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

Alex

1 Like

Ah, ok.
Tried it and seems to work. Good to know!

Thanks Alex.