Aids in AutoLISP debugging
Supported Platforms: Windows, Mac OS, and Web
Signature
(trace [function ...])
- function
-
Type: Symbol
A symbol that names a function. If no argument is supplied, trace has no effect.
Return Values
Type: Symbol or nil
The last function name passed to trace. If no argument is supplied, trace returns nil.
Remarks
The trace function sets the trace flag for the specified functions. Each time a specified function is evaluated, a trace display appears showing the entry of the function (indented to the level of calling depth) and prints the result of the function.
Trace output is sent one of the following locations
- AutoCAD Command Line window; when Visual LISP is not active in AutoCAD on Windows
- Visual LISP Trace window (Not available in AutoCAD LT for Windows, or on Mac OS and Web)
Use untrace to turn off the trace flag.
Examples
Define a function named foo and set the trace flag for the function:
(defun foo (x) (if (> x 0) (foo (1- x)))) FOO (trace foo) FOO
Invoke foo and observe the results:
(foo 3) Entering (FOO 3) Entering (FOO 2) Entering (FOO 1) Entering (FOO 0) Result: nil Result: nil Result: nil Result: nil
Clear the trace flag by invoking untrace:
(untrace foo) FOO