R Rainer@B4A Member Licensed User Longtime User Jan 5, 2014 #1 I tried to change some data storage from array to list. With an Array it was easy: Code: Copy Type Player (Name As String, Loca As Location) ' String, GPS structure Dim Players(10) as Player Players(0).Name = "Rainer" Players(0).Loca = Location1 For a List some more code is necessary: Code: Copy Type Player (Name As String, Loca As Location) ' String, GPS structure Dim Players As List Players.Initialize Dim Player As Player Player.Initialize Player.Loca.Initialize Player.Name = "Rainer" Player.Loca = Location1 Players.Add(Player) But now I run into compiler errors, because I don't know how to set the value by index ! Players.Loca.Set(0, Location1) ' ???? Players.Set(0, Location1).Loca ' ???? Many Thanks
I tried to change some data storage from array to list. With an Array it was easy: Code: Copy Type Player (Name As String, Loca As Location) ' String, GPS structure Dim Players(10) as Player Players(0).Name = "Rainer" Players(0).Loca = Location1 For a List some more code is necessary: Code: Copy Type Player (Name As String, Loca As Location) ' String, GPS structure Dim Players As List Players.Initialize Dim Player As Player Player.Initialize Player.Loca.Initialize Player.Name = "Rainer" Player.Loca = Location1 Players.Add(Player) But now I run into compiler errors, because I don't know how to set the value by index ! Players.Loca.Set(0, Location1) ' ???? Players.Set(0, Location1).Loca ' ???? Many Thanks
thedesolatesoul Expert Licensed User Longtime User Jan 5, 2014 #2 You have to get the item and then change it. Code: Copy Dim MyPlayer as Player = Players.Get(0) MyPlayer.Loca = Location1 Upvote 0
You have to get the item and then change it. Code: Copy Dim MyPlayer as Player = Players.Get(0) MyPlayer.Loca = Location1
R Rainer@B4A Member Licensed User Longtime User Jan 5, 2014 #3 Thank you very much. I'm not sure if it was a good idea to change the Array Version. Upvote 0
thedesolatesoul Expert Licensed User Longtime User Jan 5, 2014 #4 If you dont have a fixed number of items then a list is a good idea. Upvote 0