Skip navigation
Currently Being Moderated

How to convert a text to a list

Mar 29, 2012 4:31 PM

I have a text with numbers like this: 24 12 4 65 33 etc (with no itemDelimiter).

I neet to sort this numbers, maybe I need to convert this text in a list, so how can I do to convert a text in a list?

 

Thanks.

 
Replies
  • Currently Being Moderated
    Mar 29, 2012 8:32 PM   in reply to Jhon Carlo

    You could try setting the itemDelimiter to SPACE, then walk through your string item by item dropping the values into a list:

    on split str, pat
      tDelim = the itemDelimiter
      the itemDelimiter = SPACE
      tList = []
      nItems = str.item.count
      repeat with i = 1 to nItems
        tList.append( value(str.item[i]) )
      end repeat
      the itemDelimiter = tDelim
      return tList
    end
    

    Then you can sort the list returned and do what you want with it.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2012 12:58 PM   in reply to Sean_Wilson

    for completeness, here's a javascript implementation:

     

    function js_split(str, delim) {

      var tmpList = list();

      var arr = str.split(delim);

      for (var i in arr) tmpList.add(parseInt(arr[i]));

      return tmpList;

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points