1 Reply Latest reply on Feb 6, 2008 2:27 PM by Lukewig

    String convert to list

    Level 7
      Hello:
      I need to convert a string in a list, I mean:

      I have this
      text1="list1"
      text2="list2"

      Now I need to use like parameters.

      Showlist text1

      On Showlist vlist
      list1=[1,2,3]
      list2=[A,B,C]

      put vlist --I need to show the content on list1 or list2
      end

      Can you help me please?

      Thank you


        • 1. Re: String convert to list
          Lukewig Level 1
          Hi Arielle,
          There are three of ways to do it

          1. Use a propList (probably the best approach is you have a reasonably large list of lists)

          On Showlist vlist
          lookupList = [:]
          lookupList ["list1"]=[1,2,3]
          lookupList ["list2"]=[A,B,C]
          put lookupList .getAProp(vlist)
          end

          2. Use a case statement (best for a small list of lists)

          On Showlist vlist
          case (vList) of
          "list1": out = [1,2,3]
          "list2": out =[A,B,C]
          otherwise
          put "Cannot find list " & vList
          end case
          put out
          end


          3. Use Lingos "value" command

          on Showlist (vList)
          aList = value(vList)
          -- now do some error checking
          if listP(aList) then put aList
          else put "Error evaluating vList"
          end