Accessing fields inside a List.

BlitzMax Forums/BlitzMax Programming/Accessing fields inside a List.

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

'...
'a list containing all your entities:
Global Entity_List:TList = CreateList ( )

'Your entity type:
Type Entity
  Field X# , Y# , Z#
  '...
EndType
'....
'This function creates a new entity, adds it to the list and to the listbox
Function CreateEntity:Entity()
  Local e:Entity = New Entity
  ListAddLast Entity_List , e
  AddGadgetItem listbox,"Object: "+(EntityList.Count()+1),0,-1,"",e'<-- set e as gadgetitem extra
  Return e
EndFunction
'....
'In this code the events are handled
If EventSource()=listbox And EventID()=EVENT_GADGETACTION
  Local e:TEntity=TEntity(GadgetItemExtra(listbox,SelectedGadgetItem(listbox)))'Get the entity the user double clicked on
  Notify "X: " + e.X + " Y: " + e.Y + " Z: " + e.Z'Notify the entities properties
EndIf