2 Replies Latest reply on Jun 15, 2011 4:03 AM by TherionWare

    List of Lists Problem.

    TherionWare

      I have a list generated by the following lingo code:

       

      list1 = [ #a:0, #b:0, #c:0 ]

      list2 = []

       

      repeat with x = 1 to 3

         list2.append( list1 )

      end repeat

       

      this generates a list of the form

       

       

      [ [ #a:0, #b:0, #c:0], [ #a:0, #b:0, #c:0], [ #a:0, #b:0, #c:0]]

       

       

      but if I then if I say

       

      list2[2].a = 1

       

      I end up with a list that looks like this:

       

      [[#a 1, #b 0, #c 0], [#a 1, #b 0, #c 0], [#a 1, #b 0, #c 0]]

       

      Your thoughts are welcome!

       

      This doesn't happen if I explicitly create list2 without using the repeat/append loop, and can be avoided if I insert the line

       

      list2 = value(string(list2))

       

      before assigning any value to list2.

       

      Am I doing something silly with the repeat loop?

       

      Thanks,

      TW.