Hello,
I have a problem using global variables.
I have 2 modules like this:
Modul "Main": This module is used to enter some data like "size" :
Activity-Modul "Game": In this module the variables set in "Main" must be processed
I can compile the code but on run it crashes immediately. The log says:
LogCat connected to: emulator-5554
process_globals start
maininitializeProcessGlobals (java line: 293)
java.lang.RuntimeException: java.lang.NullPointerException
at ss.com.buttons.main.initializeProcessGlobals(main.java:293)
at ss.com.buttons.main.afterFirstLayout(main.java:80)
at ss.com.buttons.main.access$100(main.java:16)
at ss.com.buttons.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at ss.com.buttons.Game._process_globals(Game.java:888)
at ss.com.buttons.main.initializeProcessGlobals(main.java:287)
... 12 more
I can use the variables in sub Globals, but this doesnt help me because I need declare iCalcNewSize as global.
Heinz
I have a problem using global variables.
I have 2 modules like this:
Modul "Main": This module is used to enter some data like "size" :
B4X:
sub Process_Globals
dim iSize as int '**needs to be a global var (main.iSize)
end sub
sub myButton_Click
iSize = myEditTextSize.text
StartActivity ("Game")
end sub
B4X:
Sub process_globals
dim iCalcNewSize as int '**needs to be a global var (Game.iCalcNewSize)
iCalcNewSize = main.iSize * 10 <---crash here
end sub
LogCat connected to: emulator-5554
process_globals start
maininitializeProcessGlobals (java line: 293)
java.lang.RuntimeException: java.lang.NullPointerException
at ss.com.buttons.main.initializeProcessGlobals(main.java:293)
at ss.com.buttons.main.afterFirstLayout(main.java:80)
at ss.com.buttons.main.access$100(main.java:16)
at ss.com.buttons.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at ss.com.buttons.Game._process_globals(Game.java:888)
at ss.com.buttons.main.initializeProcessGlobals(main.java:287)
... 12 more
I can use the variables in sub Globals, but this doesnt help me because I need declare iCalcNewSize as global.
Heinz