Android Question How Do I Declare a List or Array that's Available App-Wide?

Shadow&Max

Active Member
Licensed User
Longtime User
I want to declare several lists and arrays that are available to every sub, form or module in the app. is that possible? I have used the search feature, but it's not really the most accurate and I haven't found what I needed... I read about variables, but it still isn't clear.

Can I declare an array, for example, which the entire app can use, and if so, where and how do I declare that?

If I want to write a sub that's available to everything, does it go in a class module or a code module?

I know these are basic Basic things, but I've been out of the loop for a while and am definitely rusty.

Any help would be appreciated...

Thanks in advance...
 
You can (and should) use a code module for global routines and "data" (variables, arrays, lists...); an example: DBUtils.

Activities and classes can share their variables (and lists, etc.) too and you can call their routines, but for global purpose is better to use code modules.
 
Upvote 0
Thanks... OK, again trying to not sound stupid...

Say I've got the modules main, second and general, and general is a code module I just created.

I moved the declarations of the lists, arrays and variables I want totally global to that.

However, in the modules that also use those arrays (main and second), lists and variables other than in the "general" code module, they're all red and error out as undeclared, so they don't seem very "global."

What the heck am I missing here?
 
Upvote 0
You have to put the reference to the module, along with the name of the variable.

For example:
modGlobals contains a lstCommands List;

to use it in an activity module, you should write:
modGlobals.lstCommands.Get ...
 
Upvote 0
Thanks again... That helped... the subs are executing correctly, but something now in Erel's KeyListStore is no longer working, and I can't figure out why... I'll hack away at it for a few hours and I'll get it fixed... thanks!
 
Upvote 0
Got it figured out... was a big help, thanks!
 
Upvote 0
Back
Top