Scopes and accessing method variables

What is the easiest way to do this…

Open event triggers on main window… and calls RunMyMethod1() and the method runs.

So here is my question, how would I access a string array variable that has been defined inside the RunMyMethod1 from outside the method (i.e; inside the main window).

Do I need to setup a method parameter that gets declared and then the return of that parameter is the variable?

I’m just new to this and trying to wrap my head around some of the basic concepts while reading thru the Xojo docs/books.

Thanks everyone for any help.

You don’t
Pass it in & return the modified version (i.e. a function that takes a param & returns a modified version)
OR
pass it in & modify & so it gets passed back out in its modified form
OR
declare it as a property of the window

But you can’t reach in from outside the method to grab some local variable mostly because the local disappears when the method ends (true in 99.9% of the case as locals are on the stack)

So there is no way to do something similar to this?

There are 3 ways.

  1. Create the array outside the method and pass it as a parameter.
  2. Create the array inside the method and return it as the return value.
  3. Make the array a “more global” property (property of the window or app or a module) and access it from both places.

@Tim Hare my brother! #3 was what i was looking for, simple as eating pie. Just dropped a property on the window and now I can access from everywhere like butter… :slight_smile: