Copy and paste autolisp code not working?

If you are like a lot of AutoCAD users out there, you have probably downloaded lisp code from an Internet site. Many times you are downloading a file, but in some cases you have to copy and paste the code from a webpage into Notepad or some other editor. Something we have seen one occasion when copying and pasting code is that the code contains “curly” (or smart) quote marks (ASCII characters 8220 and 8221) instead of the plain old straight quote marks (ASCII character 34).

Why does this matter? Because AutoCAD will not read or execute code with the “curly” quotes. In some applications these extended ASCII character quotes appear slanted and other times they do appear curly. The left and right characters are different. Be aware that Windows Notepad does support curly quotes, so pasting your code into Notepad will not identify this issue!

Take a look at these two autolisp lines

(setenv “CmdHistLines” “1000”) ;<- curly quotes
(setenv "CmdHistLines" "1000") ;<- straight quotes

If you copy and paste the top line to your AutoCAD command line, you will get an error: ; error: bad argument type: stringp nil
The bottom line works as expected. Can you see the difference in the quote marks?

If you were to paste the top line into the VLIDE, you would immediately see a problem.

autolisp code in the VLIDE showing error

The VLIDE does not support these extended ASCII characters and displays them as solid blocks, so this issue is very easy to spot. If you ever run into an otherwise unexplained issue with autolisp code, try opening the file with or pasting your code into the, VLIDE to make sure this is not the issue.

Please do not use Microsoft Word to edit lisp files. Curly quotes will only be one of your worries. But since I mentioned it, here is how to turn OFF curly quotes in MS Word.