Copy and paste autolisp code not working?

If you are like a lot of CAD 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 and BricsCAD 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 or BricsCAD command line, you will get an error similar to this: ; error: bad argument type: stringp nil
The bottom line works as expected. Can you see the difference in the quote marks?

autolisp code in the VLIDE showing error

Autolisp code in the VLIDE showing error

The AutoCAD 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, AutoCAD VLIDE to make sure this is not the issue. Note that the BricsCAD BLADE will correctly show the “curly” quote marks, but they will still be interpreted incorrectly if you try to execute code that contains these characters.

BricsCAD BLADE showing the curly quotes

BricsCAD BLADE showing the curly quotes

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.