Globals issue

Cableguy

Expert
Licensed User
Longtime User
Hi..

In Main Globals I setup a few of them...Globals
But when I change their value within a module, the values are NOT updated...
I was under the impression that Globals were shared by all modules...
Is this a bug ?
If Not, is there any workaraound without using the return KeyWord?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi Paulo,

Just a question, did you declare the variables as Public ?
And if you use them in another module the variable name must have the module name at the beginning seperated by a dot.
If you declare a variable in the Main module like
Public TestVariable
its name is
Main.TextVariable
in the other modules.
The same rule is valid for Subroutines and Controls.

Best regards and wishes for 2009.
 
Last edited:

specci48

Well-Known Member
Licensed User
Longtime User
Hi Cableguy,

according to Erels description (...next-version-new-features...) every module has (per default) its own global variables. If you want to use some or all of them within all modules you have to define them as public and access them in connection with the module prefix.


specci48

edit: ups ... this answer was too slow for Klaus... ;-)
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Yes, I tryed to make them public but I either get an index out of range or a syntax error...
I tryed using:
B4X:
Public Myfile=""
Doesn't Work

IT NOW WORKS....

My mistake was to declare the variable and at the same time set its value...
THAT DOESN'T WORK
What works is to declare the variable as Public
B4X:
Public MyFile
And AFTER that set its value
B4X:
MyFile=""
 
Last edited:
Top