I don't know if this helps... but maybe someone will benefit from it. Here's some code that I use to have global variables, local variables, etc. In the Main() function, I initialize the global variable pointer:
Sub Main()
g = GetGlobals(-1) ' -1 only passed this once at start of main
g.BackgroundColor = &H000000FF
<rest of your code>
End Sub
Function GetGlobals(v as Integer) As Object
if v = -1 then
m.Globals = {}
end if
Return m.Globals
End Function
Then within any sub or function (including objects) that I want to have access to the global variables, I use
g = GetGlobals(0) thus:
Sub Whatever()
g = GetGlobals(0)
g.BackgroundColor = g.BackgroundColor AND &H7F00 ' for example... accessing a global
End Sub
There's about 100 different ways to skin this cat. But if this helps.... cool. This stores all your "global" variables in the GlobalAA in a member called, surprisingly, "Globals". In the debugger you can always call "g=GetGlobals(0): ? g" if there is no local g assigned. Can call GetGlobals(0) inside any objects that need access too. I use g here, but you could use any variable (other than possibly m). Just make sure to have a local "g" reference if you need access to the globals. Don't ever pass it a -1 except the 1st time or it will wipe out your current globals. Also note that the GetGlobals() function must be at program scope (not made a member function of some other object.) This predates the GetGlobalAA() function (I think?), but still works fine. Had I returned "m" rather than "m.Globals" it would have been similar/equivalent to GetGlobalAA(). Meh.