7 Replies Latest reply on Oct 10, 2008 12:05 AM by Newsgroup_User

    convert string in a list

    Level 7
      How can I convert this string in a list

      Strings= "["a", "b"],["c", "d"]"

      I need Strings=[["a", "b"],["c", "d"]]


      thank you


        • 1. Re: convert string in a list
          Level 7
          But that isn't even a valid string. Did you make a typo?

          Arielle wrote:
          > How can I convert this string in a list
          >
          > Strings= "["a", "b"],["c", "d"]"
          >
          > I need Strings=[["a", "b"],["c", "d"]]
          >
          >
          > thank you
          >
          >
          • 2. Re: convert string in a list
            Level 7
            Yes, I concatenate two list into one list and I get "["a", "b"],["c",
            "d"]"
            I need one list like [["a", "b"],["c", "d"]]

            "Dave C" <no@no.com> escribió en el mensaje
            news:gcloqk$hem$1@forums.macromedia.com...
            > But that isn't even a valid string. Did you make a typo?
            >
            > Arielle wrote:
            >> How can I convert this string in a list
            >>
            >> Strings= "["a", "b"],["c", "d"]"
            >>
            >> I need Strings=[["a", "b"],["c", "d"]]
            >>
            >>
            >> thank you


            • 3. Re: convert string in a list
              ensamblador Level 1
              indeed your strings will give you a compile error.

              eventually, you can convert a string to its value (for example, a list, a number) using the "value" method:

              Strings= "['a', 'b'],['c', 'd']"
              StringsValue = value(Strings)
              Put [StringsValue]
              --[['a', 'b'],['c', 'd']]

              http://help.adobe.com/en_US/Director/11.0/help.html?content=07_Methods_485.html
              • 4. Re: convert string in a list
                Level 7
                A custom handler will do this for you

                -----------------------------------
                on createListFromLists list1, list2
                newList = []
                newList.add(list1)
                newList.add(list2)
                return newList
                end
                -----------------------------------

                Testing in the message window

                put createListFromLists(["a", "b"],["c", "d"])
                -- [["a", "b"], ["c", "d"]]
                • 5. Re: convert string in a list
                  James Newton, ACP Level 3
                  -- Strings= "["a", "b"],["c", "d"]"
                  --
                  -- I need Strings=[["a", "b"],["c", "d"]]


                  on Convert()

                  -- -- Because of the nested quotes, the following is invalid:
                  -- vString = "["a", "b"],["c", "d"]"

                  -- -- To get a string that looks like vString, I'm going to cheat
                  vString = string([["a", "b"],["c", "d"]])

                  delete char 1 of vString
                  delete char 12 of vString
                  delete char 22 of vString

                  -- put vString
                  -- -- "["a", "b"],["c", "d"]"

                  -- Now I can convert the string by making it look more like a list
                  vString = "["&vString&"]"
                  vList = value(vString)
                  -- [["a", "b"], ["c", "d"]] -- QED

                  return vList
                  end


                  Arielle: it looks as if you are getting this string from a field or a text member. It might make sense to add the enclosing "[" and "]" characters directly in the source, so that you can use value() directly.
                  • 6. Re: convert string in a list
                    Level 7
                    When she said

                    "Yes, I concatenate two list into one list and I get
                    "["a", "b"],["c","d"]"

                    I took that to mean she was doing something like

                    ["a","b"] & ["c","d"]

                    which would yield

                    "["a", "b"]["c", "d"]"

                    Arielle, if you will clarify what you are trying to achieve, I am sure
                    someone can provide the solution.
                    • 7. Re: convert string in a list
                      Level 7
                      Thank you to all of you

                      I needed only one list (added from other) lists like:
                      mylist=[["a", "b"],["c", "d"],["x","y","z"],["j","h","k"]] etc...
                      I mean, an array of arrays. I was trying this and it's work:
                      Strings= "["& mylist[1]&","&mylist[2]&","&mylist[4] &"]"

                      ListsConcatenate=value(Strings)


                      Thank your very much