I'm writing my first class in B4A. It will basically create a list of all of the points touched. I call the Initialize method and it works as expected. I then call Add_XY and I get an error because the ListX is Null.
I'm sure it's simple but it's not obvious to me what I need to do for this to work.
Any pointers appreciated.
I'm sure it's simple but it's not obvious to me what I need to do for this to work.
Any pointers appreciated.
B4X:
'Class module
Sub Class_Globals
Public MaxX As Int
Public MinX As Int
Public MaxY As Int
Public MinY As Int
Public ListX As List
Public ListY As List
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (X As Int, Y As Int)
MinX = X
MaxX = X
MinY = Y
MaxY = Y
ListX.Initialize
ListY.Initialize
End Sub
Public Sub Add_XY (X As Int, Y As Int)
ListX.add(X)
ListY.Add(Y)
'Mark the range of motion on the X axis
If X > MaxX Then MaxX = X
If X < MinX Then MinX = X
'Mark the range of motion on the Y axis
If Y > MaxY Then MaxY = Y
If Y < MinY Then MinY = Y
'Connect the last two points
End Sub