Window2 to Window1

Good Evening, All!

My name is Anthony, and I’ve literally just started getting into programming. I’ve tried previously, but kept getting distracted and by the time I tried to come back to it, I was right at the beginning (Not that I ever got very far!) Anyway, I realised the best way to learn was to make something practical, that would make my work life a little easier.

I’ve struggled through drop-down menus, and tick boxes changing strings, and being able to clear statements, but I am struggling immensely with copying information from a second window to the first.

Click a button
Window2 opens with 4 TextAreas and 6 TextFields - All accept string
Click a “Generate” button and all the strings are then combined into another variable String)

What I am trying to do is send that final variable to a TextArea.Text on Window1 but I cannot get it to work.

As I understand it, I cannot send any information to fields from window1, to window2.
I’ve tried using copy and paste - so the button sends to clipboard, which when the first window gets focus, dumps the variable into the textarea, but I get stuck with the focus repeating and copying the same text over and over again.

I have been unable to find a way to set either the button or textarea as global (which I understand would let me communicate with it.)
I also saw a method of using a Module, but it didn’t make sense to me. - I believe I would also need a reliable trigger to prompt the information being sent to the TextArea when Window2 closed

If anyone could help me with a work around, or point me in the right direction, I would be eternally grateful!

Thank you

Anthony

Have you read through the manuals yet? They might help your understanding of things like Modules.

Let’s say you’re trying to send the variable myGreatString to a textfield on Window1 named theResult. It would look like this:

Window1.theResult.text = myGreatString

You shouldn’t need a global variable to hold that string unless you’re trying to save it for use over and over within your program.

The Manuals and Language Reference can be found on http://documentation.xojo.com and I would highly recommend reading each of the manual books before really delving in.

Hi Tim,

Thanks for your reply. I tried the code as you have it written, changing the name of the variable and TextArea name to match (I’ve tried using that code before) - but I get “This item does not exist” when checking it for errors. I have been trying to find a way of doing this since yesterday - and not having much luck.

I couldn’t find anything to say it was not possible to move the information between windows, but couldn’t find a topic online to support it either, and give there isn’t much I can get wrong with that line of code, I just assumed it wasn’t I could do.

I’m not sure if it makes any difference, but I created Window2 from the Library list rather than putting code into the button that spawns it.

Any idea what I’m doing wrong?

I’m reading through the guides and manuals every time I come up against something that doesn’t make sense to me, or when I need an example, it’s certainly useful, but occasionally doesn’t make sense to me. I’ve been scouring the net, forums, and have a book or two for reference - but this has me stumped.

Thanks for your help

Anthony

Try the alternative setString()

Window1.theResult.setString(myGreatString)

If you don’t have any reservations about sharing your project file I’d be happy to take a peek for you if you still can’t get it to work :slight_smile:

That got it working!
Thank you very much, Tim
Really appreciate your help

Hello, for example when you type some code something like : Window2.TextField1.text=Window1.TextField1.text
You can give a tab key when the “.” has been typed, and see the options.
Just wanna say that, good luck !

Hi Frederik,

The tab options have been a big help but in this instance, the line was correct, it just would not work.
I had to re-create the app around Tim’s line, and even though everything else is the same, it works fine on the copy of my app, but not the original version. Very confusing!

Thanks for your reply