I have a particular problem with items that have references to other items imbedded in an internal list. For example, lets say I have four points (of type TPoint). One of those points is linked by a chain to the other three, and the chains have various qualities (like length, strength, etc.).
So I create a Type TChain and give it the qualities necessary. I add it to a ChainList:Tlist Field in the TPoint type. Yet, when I iterate through the ChainList for each point, looking for the other points that are chained, I get nothing. The Following sample should show what I'm trying to do.
I originally tried doing this with an array, but it became ugly very quickly... so Tlists seem to be the best option. What am I missing?
So I create a Type TChain and give it the qualities necessary. I add it to a ChainList:Tlist Field in the TPoint type. Yet, when I iterate through the ChainList for each point, looking for the other points that are chained, I get nothing. The Following sample should show what I'm trying to do.
SuperStrict Type TChain Field Size:Int Field Weight:Int Field LinkedPoint:TPoint End Type Type TPoint Field Name:String Field x:Int,y:Int Field ChainList:TList = New TList Method makeChain(Point_in:TPoint,size_in:Int,Weight_in:Int) Local TempChain:TChain = New TChain tempChain.size = size_in tempChain.weight = weight_in tempChain.LinkedPoint = Point_in self.ChainList.addlast(Point_in) End Method Method CheckChains() For Local temp:TChain = EachIn self.ChainList Print temp.LinkedPoint.name Next EndMethod EndType Local Point1:TPoint = New TPoint Point1.name = "Point #1" Local Point2:TPoint = New TPoint Point2.name = "Point #2" Local Point3:TPoint = New TPoint Point2.name = "Point #3" Point1.makeChain(Point2,1,20) Point1.makeChain(Point3,2,40) Point1.checkChains()
I originally tried doing this with an array, but it became ugly very quickly... so Tlists seem to be the best option. What am I missing?