4 Replies Latest reply on Mar 9, 2010 10:29 AM by schneb

    List Code Question

    schneb

      I have created an XML reader that is ready a CD collection. Now I would like to turn this information into a list or property list, but can't seem to figure out how to do it with mulitple titles.  Here is what one entry looks like...

       

      [#title: "Hide Your Heart",#artist: "Bonnie Tyler",#country: "UK",#company: "CBS Records",#price: "9.90",#year: "1988"]

       

      Now if this was the only title, I could easily access each of these symbols, but I can't figure out how to enter multiple items into a list. I can format the multiple items as a variable, but it would not work as a list... thinking it is just a string. I am now throwing up my hands and asking for help. Any ideas?

       

      Thanks in advance.

        • 1. Re: List Code Question
          Sean_Wilson Adobe Community Professional

          One option is to create a list of (property) lists:

          [\
          [#title: "Surrealistic Pillow", #artist: "Jefferson Airplane", #country: "US", #company: "RCA Victor", #price: "9.90", #year: "1967"], \
          [#title: "Let It Bleed", #artist: "The Rolling Stones", #country: "UK", #company: "Decca", #price: "9.90", #year: "1969"], \
          [#title: "Sgt. Pepper's Lonely Hearts Club Band", #artist: "The Beatles", #country: "UK", #company: "Parlophone", #price: "9.90", #year: "1967"]\
          ]
          
          • 2. Re: List Code Question
            schneb Level 1

            Thanks Sean,

             

            I am able to hard code in a List that will work, but I can't seem to make it load dynamically. What I mean is, I can't seem to be able ti code it where it adds the above codes within a repeat loop. For example, I can create the exact code that would work in a list, but if I add that text into a list, it is treated as a STRING and not a list. It needs to add each element with an addAt or addProp within a loop.

             

            This one is a hard one to explain, so please I implore patience.

            • 3. Re: List Code Question
              Mike Blaustein

              Try it this way:

               

              gPlayList=[]
              gPlayList.append([#title: "Surrealistic Pillow", #artist: "Jefferson Airplane", #country: "US", #company: "RCA Victor", #price: "9.90", #year: "1967"])
              gPlayList.append([#title: "Let It Bleed", #artist: "The Rolling Stones", #country: "UK", #company: "Decca", #price: "9.90", #year: "1969"])
              gPlayList.append([#title: "Sgt. Pepper's Lonely Hearts Club Band", #artist: "The Beatles", #country: "UK", #company: "Parlophone", #price: "9.90", #year: "1967"])

               

              now you will have a linear list which contains the proplists for these albums.  You can access the bits like this:

               

              put gPlayList[1]

              -- [#title: "Surrealistic Pillow", #artist: "Jefferson Airplane", #country: "US", #company: "RCA Victor", #price: "9.90", #year: "1967"]

               

              put gPlaylist[2][#artist]

              -- "The Rolling Stones"

               

              To add a new album, you could do something like this:

              newAlbum=[:]

              newAlbum[#title]="Dark Side of the Moon"

              newAlbum[#artist]="Pink Floyd"

              newAlbum[#country]="UK"

              newAlbum[#company]="Capitol"

              newAlbum[#price]="9.90"

              newAlbum[#year]="1973"

              gPlaylist.append(newAlbum)

              • 4. Re: List Code Question
                schneb Level 1

                Mike,

                 

                You are "beyond the pale" great. That was the magic bullet I needed. Thank you so much for your detailed response!

                 

                Schneb