2 Replies Latest reply on Aug 22, 2012 7:19 AM by Production Monkey

    Multidimensional Array


      Hey guys,


      i have a problem,... my actual snippet looks like this:


      on updateVars me

        pList = pXMLObj.makeList()

      if(pList.count() > 0) then

          q_count = pList[1][2].count()


          global questions


          questions = [[15],[[q_count],[6]]]

          questions[difflevel].add(pList[1][2][i][1][4],pList[1][2][i][1][3],pList[1][2][i][2][2],p List[1][2][i][3][2],pList[1][2][i][4][2],pList[1][2][i][5][2])

      end repeat




        end if






      The script is reading questions with their answers and some information from a xml file.

      I dont know how much question in every category are present, i only know there are 15 difficult levels and every question need 6 information.

      so i need a array like this:




      how do i achieve this kind of array or whats wrong with my code!?


      i always get an "at least 2 parameters epectd" error


      thanks a lot

        • 1. Re: Multidimensional Array
          Sean_Wilson Adobe Community Professional

          Show us an example of your "raw" XML, or what your pList variable holds after the makeList() method has been used on it.

          • 2. Re: Multidimensional Array
            Production Monkey Level 3

            Based off the small amount of code you provided, something like the following may work.



            global Questions


            on updateVars me

              pList = pXMLObj.makeList()

              if Not pList.count then

                put "Error:  Handler: updateVars(),  pList.count = 0"


              end if


              Questions = []  -- initialize global


              repeat with Lev = 1 to pList[1][2].count

                Levels = []

                repeat with Q = 1 to pList[1][2][Lev].count

                  _questions = []

                  repeat with I = 1 to pList[1][2][Lev][Q].count

                    _questions.add(pList[1][2][Lev][Q][I])  -- add info to _questions

                  end repeat

                  Levels.add(_questions)  -- add _questions to levels

                end repeat

                Questions.add(Levels)  -- add levels to global questions

              end repeat


            end updateVars