string to list

Discussion in 'AutoCAD' started by stevej, Aug 6, 2003.

  1. stevej

    stevej Guest

    Hello All

    How do I convert a string "9 10 11 12" into a list (9 10 11 12). I'd thought this would be easy but all cominations of ascii, vl-string->list, etc don't seem to be working. Can anyone help please?

    Steve
     
    stevej, Aug 6, 2003
    #1
  2. stevej

    mmo Guest

    It's much easier than you think. Suppose varable str holds the string containing your row of numbers, (read (strcat "(" str ")")) converts this into a list.

    With friendly greetings, M. Moolhuysen.
     
    mmo, Aug 6, 2003
    #2
  3. stevej

    stevej Guest

    Marvellous.

    Thankyou.
     
    stevej, Aug 6, 2003
    #3
  4. stevej

    Kevin Nehls Guest

    Kevin Nehls, Aug 6, 2003
    #4
  5. stevej

    stevej Guest

    Kevin,

    Thanks for that, but it didn't actually matter whether the list returned was (9 10 11 12) or ("9" "10" "11" "12"), I'd just assumed the former would be easier. Would there be any advantages using either solution over the other?
     
    stevej, Aug 6, 2003
    #5
  6. stevej

    Kevin Nehls Guest

    It depends on how you need to store the data. If you need them to stay as
    strings then I'd use one of the string parsing utilities. If you need them
    to be turned into a list of numbers I'd use the other method posted.

    --
    Kevin Nehls


    was (9 10 11 12) or ("9" "10" "11" "12"), I'd just assumed the former would
    be easier. Would there be any advantages using either solution over the
    other?
     
    Kevin Nehls, Aug 6, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.