3 Replies Latest reply on May 17, 2007 2:46 AM by www.gamesmaken.pagina.nl

    reading values in a list

    www.gamesmaken.pagina.nl
      Hi everyone,

      I have made a list and if I give the lingo command:

      repeat with x =1 to Alist.count
      put getAt(Alist,x)
      end repeat

      I get in the message window something like:

      <Object list 1 758f3f0>
      <Object list 1 8611b20>
      etc.

      The list is a pointer to another list, Alist = Anotherlist[1]. But anyhow, I want to get the values and not these object references!

      What am i doing wrong here?

      Thanks,

      Wouter

      serious games
        • 1. Re: reading values in a list
          Level 7
          Hi,

          I'm not familiar with the Object reference in your example, but this
          (slightly different notation and there is a parent script named "list"
          in the cast as well):

          on startMovie
          Alist = [script("list").new(), 2, 3, 4, 5, 6]
          repeat with x =1 to Alist.count
          put Alist[x]
          end repeat
          end

          renders this:
          -- <offspring "list" 2 242b80>
          -- 2
          -- 3
          -- 4
          -- 5
          -- 6

          So your list contains objects instead of primative values (or whatever
          they are called officially).
          Judging by your:
          Alist = Anotherlist[1]

          the list called Anotherlist contains lists of objects.

          If you want the values (or properties) from an object, use the dot notation:

          on startMovie
          Alist = [script("list").new()]
          repeat with x =1 to Alist.count
          put Alist[x].pJustAProp
          end repeat
          end

          The parentscript:

          property pJustAProp
          on new me
          pJustAProp = "just a value"
          return me
          end

          The messagewindow:
          -- "just a value"

          HTH,
          Manno


          www.gamesmaken.pagina.nl wrote:
          > Hi everyone,
          >
          > I have made a list and if I give the lingo command:
          >
          > repeat with x =1 to Alist.count
          > put getAt(Alist,x)
          > end repeat
          >
          > I get in the message window something like:
          >
          > <Object list 1 758f3f0>
          > <Object list 1 8611b20>
          > etc.
          >
          > The list is a pointer to another list, Alist = Anotherlist[1]. But anyhow, I
          > want to get the values and not these object references!
          >
          > What am i doing wrong here?
          >
          > Thanks,
          >
          > Wouter
          >
          > http://www.seriousgames.startpagina.nl
          >

          --
          ----------
          Manno Bult
          http://www.aloft.nl
          manno@xs4all.nl
          • 2. Re: reading values in a list
            Level 7
            > <Object list 1 758f3f0>
            > <Object list 1 8611b20>

            That looks very much like you are using new DOM-syntax to access a list
            or other high-level data type from a MIAW or LDM, something like:
            -- from the stage:
            tList = window("MIAW").movie.returnAsList()

            The only way I know of to get "regular" objects returned is to revert to
            'tell':
            tell window("MIAW") to tList = returnAsList()

            However, <Object list 1 758f3f0> is still a list under the hood; it's
            just that you can't scan it by eye in the message window or Object Inspector
            • 3. Re: reading values in a list
              www.gamesmaken.pagina.nl Level 1
              Sorry Guys,

              I got a 'last minute job' and had to leave my programming work for until now. The object, is actually an extra. I found out that if I put the lingo in a sprite beheaviour in stead of in the movie script everything worked !?

              thanks for helping me.

              W.

              read my open source book on projectmanagement and software development:
              www.projectmanagement-training.net