Sharing Variables Between Screens and Functions

X has the ability to pass variables between screens. (Classic does not)

To do this setup an application with two screens. Screen1 and Screen 2.

In Designer:

On Screen1, place a label and a button. Set the text of the button to Go To Screen2

image

On Screen2, place a label and a button; Set the text of the button to Get Screen1 Text.

image

Blocks

Screen1

Set your variable. I entered basic text saying Nothing Entered so we know what state the variable is in when it is presented.

You will see here that we set the variable to what was entered in the text box once the Button is clicked. we then move to Screen2.

Screen2

Here we show a few more concepts.

  1. You see the variable from screen one is passed once we click the button. But we are calling a function.

A function allows us to group certain tasks together, and we can send information when we call a function for it to perform. Here we have said:

"When the button on Screen2 is clicked, please call the function named whatWasSaid and send the “Current Day of the Week” as the Extra Stuff information.

When the whatWasSaid function is called it takes the “Extra Stuff” (being the day of the week) and adds it to the variable from Screen1 (using the Join component)

To be able to add the Extra Stuff to a Function, use the little gear.

image

Drag the Input Name

image

Then rename the X by click and typing what you want. I put Extra Stuff

==================
Cross Screen Variables, and a Function all at once.

Here is the project to play with.

https://x.thunkable.com/copy/5394993b9f0848b721d8b464f83fd39a

2 Likes

Thanks for sharing Cian!

1 Like

How do i make the text of a TextInput go to a label in another screen? . I tried doing something like this but I had to make some modifications as i didn’t need the current day of the week
@Cian_O_Sullivan

Hey @playgamess8968x7sua - can you share a screenshot of what you’ve tried so far and we can point you in the right direction.

Thanks!

1 Like

Hey there,
Thanks for reaching out. Today, I was surprised to know that somehow my modifications actually worked
when i live tested the app on my phone.
It’s all cleared now and I’ve successfully done what i wanted to do

Thanks,
Noodle Boy

1 Like