Global Variables/Properties

I am having trouble declaring global variables/properties. I have inserted a Module and have create a method under the module. defined my variables in the method. But when I try to refer to them Xojo says they do not exist.

Can someone please help.

Thanks in advance

Noob here, but I ‘think’ you need to create a Property with Global Scope under your Module, not a Method that contains variables.

Apologies if I’ve gotten that wrong. :wink:

Variables defined within a method are only accessible from within that method, and typically cease to exist when the method returns. To create a global and persistent variable add it to the module as a property.

So I did this:

Create a (Global Scoped) Property under my Utilities Module:

Create a variable in a Method

Call both the Property and the Method-defined variables from another Method

The Module Property is available, the Method Variable is not.

Hope that helps?

coming here for this, but there are no images :frowning:

Information about properties is in the User Guide:

The link used inside the html page (this page) are no more there (Error 404 when activated).

For my purposes, I have been moving away from modules and, whenever it makes sense, putting public methods and properties in the Application class. Then I call them with app.theName. On the property/variable front, I keep public/global ones to a minimum, under the “Global Variables are a Bad Thing®” principle. :slight_smile:

it’s been a while since I made the change, but if you have a global variable theApp and set it to = application
then the properties are accessed faster.