Setting and Getting Stored Variables - Keep getting Null

Hi,

I am trying to persist some stored variables by setting and getting them, but for some reason I keep getting a null value returned. I have followed a few threads and tried to replicate this but cannot seem to get the value.

thunk_1

thunk_2

The screen is not the main screen so it opens once I click on a button to go there, not sure if that makes any difference and it’s null on my android and pc test.

I also tried a text value incase it did not like a Boolean.
thunk_3

Any help would be appreciated.

Thank you,

Paul

You need to stop using the set stored variable " " block.

That block is for dynamic variable names. So when you put the stored variable test_sr_gm block in where the variable name should be, you’re telling Thunkable to get the value of a variable with the value from the stored variable. So let’s say that stored variable test_sr_gm has the value “43”. Your blocks would be attempting to reference a stored variable called 43. But that doesn’t exist so you see “null”.

Instead, use the set variable block at the top of the variables drawer.

HiTatiang,

Thanks for responding to my query. Sorry but I am completely confused by that. I am not sure then how I would actually set a default value if it does not exist. I am still learning on the whole block config.

I tried this, but that did not work either.
thunk4

I then put the set variable at the top of the block, but that was the same.
thunk5

Still learning sorry.

Thank you

You should be using variables this way:

1 Like

Hi Tatiang,

Rightio. I got you now. Yes that makes more sense and thank you for taking the time to explain it for me.

It works great now.

Thank you very much.

1 Like

You’re welcome. You can help others by clicking the solution checkbox for my post.

1 Like