Search code examples
autolisp

Convert Type Output to String


is it possible to collect the output of the type function and return it as a string? I can write out a list of conditions for each type of output this function can produce, but I'm hoping I can just convert the output directly into a string variable.

(type "Test")
STR ;<--- System value type

(cond ((= 'STR (type "Test")) "STR"))
"STR" ;<- String value type

Solution

  • After some additional research, I found these two functions: vl-princ-to-string and vl-prin1-to-string.

    (vl-princ-to-string (type "Test"))
    "STR"
    
    (vl-prin1-to-string (type "Test"))
    "STR"