M MbedAndroid Well-Known Member Licensed User Longtime User Nov 26, 2015 #1 i'm facing something with b4j when i define a type for example type mytype(a(64) as int, b(64) as int) next i define a global dim new as mytype in the code i do new.a(3)=14 the program crashes ...with nullpointer exeption .. why? b4j accepts the array in the type, no errors given but i cant write into it
i'm facing something with b4j when i define a type for example type mytype(a(64) as int, b(64) as int) next i define a global dim new as mytype in the code i do new.a(3)=14 the program crashes ...with nullpointer exeption .. why? b4j accepts the array in the type, no errors given but i cant write into it
LucaMs Expert Licensed User Longtime User Nov 26, 2015 #2 You must initialize "new" new.Initialize new.a(3) = 14 log(new.a(3)) Upvote 0
M MbedAndroid Well-Known Member Licensed User Longtime User Nov 26, 2015 #3 just checked the code the global is initialized, but it might be the problem that the type i defined contains many things, not only the arrays in fact what i do is for example: type new(a as int, b as int, c(64) as int, d as float etc Last edited: Nov 26, 2015 Upvote 0
just checked the code the global is initialized, but it might be the problem that the type i defined contains many things, not only the arrays in fact what i do is for example: type new(a as int, b as int, c(64) as int, d as float etc
LucaMs Expert Licensed User Longtime User Nov 26, 2015 #4 You can add "many things" in a Type, it should work. The problem is elsewhere, for sure. Anyway, I suggest you to use a Class instead of Types. Upvote 0
You can add "many things" in a Type, it should work. The problem is elsewhere, for sure. Anyway, I suggest you to use a Class instead of Types.
M MbedAndroid Well-Known Member Licensed User Longtime User Nov 26, 2015 #5 yes i noticed this already copying the type to a new project something else is causing this problem edit: found it, somewhere in the startup i was reading the global back with saved data, and the data wasnt updated to the new type... stupid me, forget the save the new format Upvote 0
yes i noticed this already copying the type to a new project something else is causing this problem edit: found it, somewhere in the startup i was reading the global back with saved data, and the data wasnt updated to the new type... stupid me, forget the save the new format
LucaMs Expert Licensed User Longtime User Nov 26, 2015 #6 MbedAndroid said: type new(a as int, b as int, c(64) as int, d as float etc Click to expand... Are you using exactly this definition? In the first post you used MyType and a variable "new" as MyType Upvote 0
MbedAndroid said: type new(a as int, b as int, c(64) as int, d as float etc Click to expand... Are you using exactly this definition? In the first post you used MyType and a variable "new" as MyType
M MbedAndroid Well-Known Member Licensed User Longtime User Nov 26, 2015 #7 see post #5, problem fixed, thank you Upvote 0
LucaMs Expert Licensed User Longtime User Nov 26, 2015 #8 This works ("new" is a bad type name, of course ) Code: Copy Type new(a As Int, b As Int, c(64) As Int, d As Float) Dim a As new a.Initialize a.c(2) = 5 Log(a.c(2)) Upvote 0
This works ("new" is a bad type name, of course ) Code: Copy Type new(a As Int, b As Int, c(64) As Int, d As Float) Dim a As new a.Initialize a.c(2) = 5 Log(a.c(2))