AutoCAD 2002 Bible

Скачать в pdf «AutoCAD 2002 Bible»

In the first example, you define a function that is guaranteed to fail. You can type this in the Visual LISP editor and load it:

;;; The function below will produce an error

;;; because strcat concatenates strings.(defun Error-Prone-Code () (strcat «This is will never print the number: » 1)


Before you continue you need to select Debug О Break on Error. By selecting this menu option, Visual LISP enables you to jump to the error in your source code automatically.

Using the function error-prone code produces an error because strcat concatenates strings, as the following demonstrates. You can type this at the console:

(Error-Prone-Code) J

Visual LISP responds with the following:

; error: bad argument type: stringp 1


Once you receive the error, choose Last Break on the Debug toolbar. Visual LISP places you in the line in the code where the error occurred.

How can you find the source of the problem in a routine? To answer this question, you often need to perform some detective work. Visual LISP provides a wealth of debugging tools, which you can leverage when you encounter an unplanned “enhancement” or bug.

Step-by-Step: Finding the Last Break

1.    Open a drawing in AutoCAD using the Start from Scratch option.

2.    Start Visual LISP and start a new file.

3.    In the Visual LISP Editor, type the following:

;;; The function add-3-numbers will not produce ;;; an error if all of its arguments are numbers. (defun add-3-numbers (numl num2 num3)

Скачать в pdf «AutoCAD 2002 Bible»