Good morning,
As you know, I'm facing some troubles with Global vars.
The fact is that if I have a var in a code module, for instance, I can change it.
But here's the problem: supose I have a string var called Data in Module1 with the value "None".
If I, in the Activity_Create, put something like this:
I get the value 777. Ok.
If I create a Sub, say Function1, and include it like this:
I also get 777.
BUT, supose I do this:
I'll get 777 IF the routine is as it is. But I'll get None, if Function1 is a "catch" function, like for example:
Sub JobDone (Job As HttpJob)
Module1.Data = "777"
...
or
Sub MyWifi_FoundLocation ()
Module1.Data = "777"
...
In these cases, it seems that there's no time for the Function1 assign the new value to the var.
And Activity_Create doesn't catch it - perhaps because it runs aside Function1 at the same time?
Maybe I'm seeing this wrong.
Kind regards,
Kepler
As you know, I'm facing some troubles with Global vars.
The fact is that if I have a var in a code module, for instance, I can change it.
But here's the problem: supose I have a string var called Data in Module1 with the value "None".
If I, in the Activity_Create, put something like this:
B4X:
Module1.Data = "777"
Msgbox(Module1.Data,"Info")
I get the value 777. Ok.
If I create a Sub, say Function1, and include it like this:
B4X:
Sub Function1 as Int
Module1.Data = "777"
Msgbox(Module1.Data,"Info")
End Sub
I also get 777.
BUT, supose I do this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
dim res as Int = Function1
Msgbox(Module1.Data,"Info")
End Sub
Sub Function1 as Int
Module1.Data = "777"
End Sub
I'll get 777 IF the routine is as it is. But I'll get None, if Function1 is a "catch" function, like for example:
Sub JobDone (Job As HttpJob)
Module1.Data = "777"
...
or
Sub MyWifi_FoundLocation ()
Module1.Data = "777"
...
In these cases, it seems that there's no time for the Function1 assign the new value to the var.
And Activity_Create doesn't catch it - perhaps because it runs aside Function1 at the same time?
Maybe I'm seeing this wrong.
Kind regards,
Kepler