How do you use stored variables across screens in thunkable x?

I’m a beginner so please help on this one. So I know how to use stored variables in the same screen, but if you ask me how to use stored variables across screens, I don’t know. So if anyone could help me, that would be great!

Thanks.

1 Like

Exactly the same way you use it in one screen apart from the initialize block.

Once you initialize an app variable or a stored variable or a cloud variable it can then be used every where in the app just by using the set variable block or assign its value to another variable or another component such as a Label`.

2 Likes

thanks very much.

1 Like

One question though @muneer, I know I should have asked this yesterday but there are two set variables in the variables section and i also don’t really get how to do it though. Do you mind sharing the blocks so can take a look of how it’s supposed to work. So I hope you don’t mind at all

Thanks a lot.

1 Like

These are the available variable types
image

When you add a variable you can select what type you want to initialize it to
image

An app variable can have a default value (Initialized value). But the other two types can not be given a default value when initializing.
image

You can assign the variable different values using the set block
image

The main difference between an app variable and a stored variable is that the app variable will retain its value as long as the app is in use. Once the app is closed, the app variable is removed from memory.

The stored variable will retain its value even after the app is closed. This is useful for setup options or to store the user name of the user of the app.

The other set of variable are dynamic variables. They can be used anywhere and do not require initialization.
image

To read or display the value of the variable you use the block with the variable name this way.
image

The documentation is covering the same but in details.

Hope this makes it clear.

2 Likes

Wow. This is a really good explanation. Thanks a lot.

1 Like

But how will it know if a specific component is the stored variable?

1 Like

The stored variable is a variable not a component. You can store any data you want and you can always check if it is null or the length is 0 which means it is empty otherwise it has a value that you have stored in a previous session of your app.

See this example
image

1 Like

Oh ok that is much clearer. Thanks. :slightly_smiling_face:

1 Like

Hi @muneer,
I have been experimenting with the variables

The above code should display the text of the input box into 1 label or the other depending on the button I press.

When I use app variable, it works. However the when I switch to another screen, the value of the variable is reset to its initialised value.

When I use stored variable, it simply doesn’t work (within the screen).

What am I missing?

1 Like

Can you share your project so I can have a look?

1 Like

Sure, just let me get the link.

1 Like

Here is the link: Thunkable

1 Like

I fixed the project. Check it
https://x.thunkable.com/projectPage/6198ce3396d8fe00102e6850

note that this
image
is not similar to this
image

1 Like

Thanks a lot for fixing my project.

Somehow, there must be a bug since the first time I previewed it, it worked, but now it doesn’t strangely.

Do you know the cause of this?

1 Like

I did not understand, can you explain?

Remember, I did not change the name of the project so make sure you preview the corrected one not the old one.

1 Like

I had previewed the new one and it seems that the buttons for storing don’t work when I type something in. Is this just me or is it for both of us?

1 Like

Can you explain in more details?

What are you doing and what are you expecting and what the app results in?

1 Like

So the problem is @muneer is that basically I when I type in the text that I want, and then click the either two of these buttons, it still shows it’s original text, and when I go back to screen 1, the text that I put in is not there.

There is a problem with the app @muneer. So when I type in the text that I want, it seems to not reply and put the text in the label as I click the button. Is this just me? Or is it actually not working?

1 Like