object help please

BlitzMax Forums/BlitzMax Beginners Area/object help please

it compiles now thanks

but throws an error:'trying to access field or method of null object'

here is the actual method:

Method add_gadget(o:gui_element)
gadget_list.addlast(o)

-this is the line that throws the error -
o.gadget_number=gadget_list.count()

EndMethod

im absolutely sure that gui_element has a field called gadget_number

dont know why it does this