Android Question expected receiver of type anywheresoftware.b4a.objects.collections.List, but got null

bartv

Member
Licensed User
Longtime User
Hello all,

I'm trying to work my way through an xml file given to my class. I'm using the sax parser, and am putting the elements and attributes of intrest in Lists of Types I created for the occasion.
Upon initializing a list object in an instance of a type, the error occurs.

Here goes the necessary minimum :
The XML file:
HTML:
    <part name="klasse" showhow="" backcolor="" color="">
        <option id="k1" text="1e klasse" />
        <option id="k2" text="2e klasse" />
    </part>

Some code:
B4X:
'Class module
Sub Class_Globals
    Private Plst As List
    Type Part(name As String, showhow As String,options As List)
    Dim XSax As SaxParser
End Sub

Public Sub Initialize(xml As String)
    Dim inp As InputStream
    inp = File.OpenInput(File.DirAssets, xml)
    XSax.Initialize
    Plst.Initialize
    XSax.Parse(inp,"XSax")
    inp.Close
End Sub

Sub XSax_StartElement (Uri As String, Name As String, Attributes As Attributes)
    Select Name
    Case "part"
        Dim pt As Part
        pt.name = Attributes.GetValue2("", "name")
        pt.showhow = Attributes.GetValue2("", "showhow")
        pt.options.Initialize
        Plst.Add(pt)
    End Select
End Sub

With my beautiful error on the line
B4X:
        pt.options.Initialize

Any hints as to why this occurs are appreciated.
 
Last edited:

bartv

Member
Licensed User
Longtime User
Thanks, Erel.
I considered
B4X:
pt.options.Initialize
to be a 'writing' instruction, and I had already written to the other fields of pt, so it never crossed my mind. Will try it this evening.
 
Upvote 0
Top