Android Question ? Can someone explain to me why Class Module globals can not be referenced in module methods?

Lee Gillie CCP

Active Member
Licensed User
Longtime User
1762485870852.png
 

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Is it a class o code module?
class modules should have a Class_Globals section, not a Process_Globals
Yes I think you are 100% on this. I did research and found that both Class_Globals and Process_Globals can not both exist in a single file. The answer it seems is to move all of the Process_Globals I have declared to another file, and to ONLY use Class_Globals for my instance variables. Thank you for this hint.
 
Upvote 0

Lee Gillie

Member
Licensed User
Longtime User
So you added Process_Globals on purpose?
bad Idea… classes can have multiple instances, so Globals are out of context
I will admit I have been using B4A a very long time, but the problem is I only have 1 project in it, and that means I only ever work with B4A once every 1 or 2 years. Across those gaps in time I forget most of the nuances I was versant in on my last round of work. I asked AI for a quick rundown of module types, scope, lifetime, singletons and it made my blunder very obvious, and fully explains the struggle I was having trying to define both a singleton global context, and also an instance context in the same source file. Seemed to me like it should be possible, and there were no compile complaints about specifically having both kinds of classes defined in one file, there was just a lot of odd appearing behavior I could not reconcile.

I moved EVERYTHING that is global, and singleton to an existing global module. And separated out that which is related to instance context, and it is coming together fine now. 2 days ago, I did not have this clarity.

I truly appreciate the replies from everyone who did, but there was one post especially that gave me the first hint. Thank you all. B4A has such an awesome community of users!
 
Upvote 0
Top