complex type declaration

r3d3

Member
Licensed User
Longtime User
I have an application composed by 2 files:
- Main
- DEVICE (class module)

I try to declare a complex type for a public variable inside my class module (DEVICE):

---------------------------------
DEVICE Class
--------------------------------
B4X:
Sub Class_Globals
    
    Type strDEVICE_Description(name As String, version As String)
    Type strDEVICE_Interface(name as string, category as string)

    Type strDEVICE(desc As strDEVICE_Description, inter As     strDEVICE_Interface)

    public mydevice as strDEVICE

    mydevice.desc.name ="toto"
    mydevice.desc.version="1.0"
    mydevice.inter.name="BT"
    mydevice.inter.category="2"

End Sub

Public Sub Initialize

End Sub
in my Main module, i try to print the content of this public variable mydevice

----------------------------------
MAIN module
---------------------------------
B4X:
Sub process_global

    Dim dev As cDEVICE

End sub

Sub Activity_Create(FirstTime As Boolean)
   
        dev.Initialize()

   Log(dev.mydevice.desc.name)

End Sub
no problem during the compilation, but i have a java error during the execution

java.lang.NullPointerException

i think i make a mistake concerning the allocation of the variable but i don't know where ...

thanks for your help

:sign0085:
 
Top