I have recently started making one of my Android apps on Thunkable X so that it can be available for iOS. The option to open a new screen with a ‘startvalue’ is a major part of the code in my Android app and saves me from having hundreds of different screens. Does anyone know when startvalues will come to Thunkable X, and if not, what I could use as an alternative?
To transfer data between screens, use Local Storage
Thanks! How would I get started?
First, look at the documentation
After that on one screen, save the value in the Local Storage, then go to another screen and in the Starts block get this value from the Local Storage
Hi - here is my issue. In brief, terms, what I’m trying to do is have the text on a screen change when a different button is pressed to open it (there are many different buttons that lead to this same page, and all need different results when the page starts). The local storage works, however when one button to open the destination screen is pressed, the destination screen will change once and then stay the same for any other buttons that also open that destination screen. E.g. in the blocks below, if I press the cheese button, the destination screen will change, yet the butter button, when pressed, will then also open the destination screen with the values for cheese. I hope this isn’t too confusing. Thanks.
Sorry, but I do not see anything in the image - too small and vague. But from your blocks I see that the algorithm is not compiled correctly, so it does not work.
Please could you elaborate more on how the algorithm isn’t compiled correctly? I’ve re-uploaded the images in a larger size.
Place the block “navigate to” inside the storage unit. Do you understand why this is necessary?
Purple blocks with a notch inside the “then do” are assynchronous blocks. Therefore, for reliable and correct operation, they need to be nested into each other in order to obtain the correct sequence of execution of the algorithm.
Yes, I’ve done this. The issue is that both values that are intended to happen separately (one for each button) onto the destination Screen 9 both happen at the same time on Screen 9 - is there some kind of ‘if’ statement I could use to stop this from happening?
There are, look at them in the palette of blocks.
I’ve found the ‘if’ statement block, but are there any such as if ‘getlocalstorage value = “value”’ then…? My issue is that the values for different things happen at once instead of separately and I don’t know how to solve this. Thanks.
Check the value of the “value” block before the comparison operation. You compare var value with the “Butter”. So look at what’s in the value block.
Thanks for that - I’ve realised the issue and fixed it all yet the same problem still persists - the changes on the destination screen happen simultaneously and are not separate. I’ve attached the new blocks below.
In the “if do” block, you have a green “value” block. Tell me, what value is stored in this block? First create a variable and assign it some value, and then compare this value with another value. And you have the opposite, first you use a non-existent variable “value”, and then create it.
The value can be two different texts, both shown above, depending on what button is used to open the destination screen, right? Also please can you give me more details on how to create a variable and assign it a value, perhaps some example blocks? I’m not sure I fully understand. Thanks!
You use the purple block LocalStrage Get. This block returns the value at the specified key in the local variable value. A local variable is a variable that does not exist outside the block in which it is defined. Therefore, you need to first get a value from Local Storage in the value block, and only then perform a comparison operation. And in your code, you first make a comparison, and then you get the variable value.
Correct procedure of actions
Did you understand your mistake?
In addition to @actech’s great advice, you might also want to use a
Screen.Open block rather than the
Screen.Starts block (see the doc here). I’m guessing that you probably want to do that logic each time you open the Screen.
Thanks Mark and @actech!
I’ve actually found a way around it now. Thanks for all the help today.