Android Question Type initializing

wroyw

Member
Licensed User
Hi,

I have a own class where I define a variable in Class_Globals :

type T1 ( v1 as float , v2 as float )

type T2 (V3 as float , V4 as T1)

but if I want change the V4 value like this :

V4.V1 = 1

I get an error : java.lang.NullPointerException: Attempt to write to field 'float b4a.example.csv3$_V4.V1' on a null object reference

What make I wrong ?
 

wroyw

Member
Licensed User
sorry thats right

Class_Globals :

type T1 ( v1 as float , v2 as float )
type T2 (V3 as float , V4 as T1)
public MyVar as T2

and in my code :

MyVar.V4.V1 = 1

(V4 = NULL in degugger)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Did you initialized your customtype?
B4X:
myvar.initialize
 
Upvote 0

wroyw

Member
Licensed User
hmm, now I have another problem ...

Class_Globals:
Type T1 ( Bool1 as boolean , Bool2 as boolean)
Type T2 (Int1 as Int , Bool as T1)
Type T3 (Float1 as float , Type2(3) as T2)
public MyType as T3

Initialize:

MyType.Initialize

but now is MyType.Type2(0).T1 = Null ...
 
Upvote 0

wroyw

Member
Licensed User
thanks
B4X:
Class_Globals:
Type T1 ( Bool1 as boolean , Bool2 as boolean)
Type T2 (Int1 as Int , Bool as T1)
Type T3 (Float1 as float , Type2(3) as T2)
public MyType as T3

Initialize:
MyType.Initialize

Why is is MyType.Type2(0).T1 = Null ?
 
Last edited:
Upvote 0
Top