How to change a symbol to a string ?

Discussion in 'AutoCAD' started by Marcel Goulet, Oct 1, 2004.

  1. Hi,

    I need to change a symbol : (c:scale) to a string "(c:scale)".

    Is that possible ?
     
    Marcel Goulet, Oct 1, 2004
    #1
  2. Marcel Goulet

    dblaha Guest

    Please define what you mean by the term "symbol".


    Dave
     
    dblaha, Oct 1, 2004
    #2
  3. Marcel -

    maybe (vl-princ-to-string '(c:scale)) ?

    if you don't quote the function it will be called.

    You may also want to look at the atoms-family function.

    Peter
     
    petersciganek, Oct 1, 2004
    #3
  4. Marcel Goulet

    David Bethel Guest

    I forget who wrote this, but I've had since 1998.


    ;converts a quoted symbol to a string
    (defun symstr (name)
    (if (= (type name) 'SYM)
    (
    (list
    (if (boundp name)
    (cons '/ (atoms-family 0))
    (cons '/ (cons name (atoms-family 0)))
    )
    (list setq name 0)
    (list car (list atoms-family 1))
    )
    )
    nil
    )
    )


    -David
     
    David Bethel, Oct 2, 2004
    #4
  5. Marcel Goulet

    Dan Allen Guest

    Command: (defun c:foo () (princ "foo"))
    C:FOO

    Command: (vl-princ-to-string c:foo)
    "#<SUBR @02e5b5a0 C:FOO>"

    Command: (vl-princ-to-string (c:foo))
    foo"foo"

    Command: (vl-princ-to-string '(c:foo))
    "(C:FOO)"
     
    Dan Allen, Oct 2, 2004
    #5
  6. Marcel Goulet

    RaghuMN Guest

    Dan,

    How to do the reverse? String/Character to variable name?

    Thanks,

    MNRaghu
     
    RaghuMN, Oct 5, 2004
    #6
  7. Marcel Goulet

    Rusty Gesner Guest

    Use the READ function.

    - Rusty
     
    Rusty Gesner, Oct 5, 2004
    #7
  8. Here are three methods I was told about here -
    (vl-symbol-value (quote (strcat "C:" CNAME))) ;does NOT generate warning
    during fas build
    (eval (list (read (strcat "C:" CNAME)))) ;generates warning
    during fas build
    (apply (read (strcat "C:" CNAME)) nil) ;generates warning
    during fas build
     
    Alan Henderson @ A'cad Solutions, Oct 5, 2004
    #8
  9. Marcel Goulet

    RaghuMN Guest

    Alan and Rusty,

    Thanks for the solutions.

    MNRaghu
     
    RaghuMN, Oct 6, 2004
    #9
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.