Number to string

Discussion in 'AutoCAD' started by Adesu, Dec 2, 2004.

  1. Adesu

    Adesu Guest

    I have program to convert from string to number,like this
    ; s2n is stand for string to number
    ; Design by Ade Suharna <>
    ; 29 November 2004
    ; Program no.142/11/2004
    ; Edit by Alaspher<>11/29/04 1 ).
    (defun c:s2n ()
    (vl-load-com)
    (setq ss (ssget))
    (setq ent (ssname ss 0))
    (setq dxf (entget ent))
    (setq tex (cdr (assoc 1 dxf)))
    (setq t2n (vl-string->list tex))
    (setq assoc1 (vl-string-trim "()" (vl-princ-to-string t2n))) ; 1).
    (setq tex1 (cons 1 assoc1))
    (setq ed (subst tex1(assoc 1 dxf) dxf))
    (entmod ed)
    )
    Now I want convert again from number to string,this below
    "65 100 101 115 117" to "A d e s u",how to do?
     
    Adesu, Dec 2, 2004
    #1
  2. Adesu

    Adesu Guest

    Sorry,I've got ,here is my code
    ; n2s is stand for number to string
    ; Design by Ade Suharna <>
    ; 30 November 2004
    ; Program no.143/11/2004
    ; Edit by Ade Suharna 2/12/2004 1).
    (defun c:n2s (/ ss ent dxf tex ntex mtex
    oritex tex1 ed)
    (while
    (vl-load-com)
    (setq ss (ssget)
    ent (ssname ss 0)
    dxf (entget ent)
    tex (cdr (assoc 1 dxf))
    ntex (strcat "(" tex ")")
    mtex (read ntex) ; 1).
    oritex (vl-list->string mtex) ; 1).
    tex1 (cons 1 oritex)
    ed (subst tex1(assoc 1 dxf) dxf))
    (entmod ed)
    )
    (princ)
    )
     
    Adesu, Dec 2, 2004
    #2
  3. Do the (itoa) and (rtos) functions not do what you want?
     
    Kent Cooper, AIA, Dec 2, 2004
    #3
  4. Adesu

    BillZ Guest

    (vl-list->string '(65 100 101 115 117))

    Bill
     
    BillZ, Dec 2, 2004
    #4
  5. Adesu

    BillZ Guest

    Oh to convert the string to a list of numbers.

    (read (strcat "(" "65 100 101 115 117" ")"))


    Bill
     
    BillZ, Dec 2, 2004
    #5
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.