I'm trying to create an roList where each element is an roAssociativeArray. My ultimate goal is to have a list where each element is multiple roAssociativeArray's, but I figure if I can't get the simple case to work, the multiple roAssociativeArray issue is hopeless. Anyway, here's my code and its output. Can anybody see where I'm going wrong?
l = CreateObject("roList") print "New list:";l.Count();" entries" obj1 = CreateObject("roAssociativeArray") obj1.str = "one" obj1.num = 1 l.AddTail(obj1) obj1.str = "two" obj1.num = 2 l.AddTail(obj1) obj1.str = "three" obj1.num = 3 l.AddTail(obj1) obj1.str = "four" obj1.num = 4 l.AddTail(obj1) print l.Count();" entries" l.ResetIndex() for each li in l print li.str, li.num end for
New list: 0 entries 4 entries four 4 four 4 four 4 four 4
As you can see, all the entries are the same. The same thing happens if the GetHead() and GetTail() functions are used on the roList. Any help would be greatly appreciated.
Ah... I get it! I knew it had to be something simple. It always makes me wonder about garbage collection when new objects get created, so I try to just reuse an old one. I can tell you I've overwhelmed the box by creating thousands of objects that were only used for a short time and then discarded. I prefer to do my own memory management!