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.
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.
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`.
thanks very much.
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.
These are the available variable types
When you add a variable you can select what type you want to initialize it to
An app variable
can have a default value (Initialized value). But the other two types can not be given a default value when initializing.
You can assign the variable different values using the set block
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.
To read or display the value of the variable you use the block with the variable name this way.
The documentation is covering the same but in details.
Hope this makes it clear.
Wow. This is a really good explanation. Thanks a lot.
But how will it know if a specific component is the stored variable?
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
Oh ok that is much clearer. Thanks.
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?
Can you share your project so I can have a look?
Sure, just let me get the link.
Here is the link: Thunkable
I fixed the project. Check it
https://x.thunkable.com/projectPage/6198ce3396d8fe00102e6850
note that this
is not similar to this
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?
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.
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?
Can you explain in more details?
What are you doing and what are you expecting and what the app results in?
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?