Home » ZWSchool » 1 MIN 1 CAD: Get a Correct Lisp in 1 Minute

1 MIN 1 CAD: Get a Correct Lisp in 1 Minute

zwcad_lispdebugger
With 10 years of lisp writing experience, Arphone, ZWCAD Deputy Manager for Application R&D, shared with us how to increase the accuracy of Lisp programs by Lisp Debugger in ZWCAD 2020.

ZWCAD supports Lisp since its first version, but doesn’t have a debugger for a long time. So in the old days if we want to debug a Lisp program, we might have to copy the codes line by line to ZWCAD command line to find out the error. However, sometimes this method does not work well. Let’s take the following program I wrote to define FOO command and call BAR function as an example.

zwcad_lispdebugger_1

It is difficult to debug these codes line by line because inside function FOO there is a mapcar function calling a lambda expression.

The good news is, now we have Lisp Debugger in ZWCAD 2020, to better debug our Lisp programs in ZWCAD. This tool is in fact an extension of Visual Studio Code, which is a lightweight but powerful source code editor from Microsoft®, and is free and open source. This extension and VSCode are installed along with ZWCAD 2020. Of course, you can also download VSCode from Microsoft®’s website and install ZWLisp debugger extension from its extension market.

zwcad_lispdebugger
Figure 1. ZwLisp in Microsoft® Extension Market

Come back to the FOO Lisp. So how do I debug it in ZWCAD 2020? First of all, I launch VSCode by running command VLIDE or VLISP. You may ask whether VSCode can be launched manually, but I won’t suggest that because VLIDE or VLISP will do one more important thing except for launching VSCode – to notice ZWCAD to collect debug information. In other words, to tell ZWCAD to be prepared for the debugging.

zwcad_lispdebugger
Figure 2. The interface of VSCode launched by VLIDE or VLISP

Then I open the source file in VSCode and do some necessary configuration to start the debug session. I choose Attach to ZWCAD as the debugging mode, since I am going to attach the debug session to a running ZWCAD process. If you need to start a new ZWCAD process, you can choose the Launch mode.

zwcad_lispdebugger
Figure 3. Select debugging mode

After the debug session is launched, I go back to ZWCAD and load the source file bar.lsp. Please notice that this step should be done after running VLIDE or VLISP command because ZWCAD should collect information while loading the source file.

zwcad_lispdebugger
Figure 4. Load the source file in ZWCAD

And then we can run FOO command and when an exception occurs it will be shown in VSCode, including its location, call stack and variable information.

zwcad_lispdebugger
Figure 5. Debug the program in VSCode

After the error was found, the debug session will be disconnected, so if I want to debug the FOO Lisp again, I need to launch another debug session again.

This debugger can be very helpful for us to find out what is the problem in our Lisp programs. If you want to learn more, you can watch this video. And if you have any question, welcome to discuss with me in the comment area.

Arphone Pei

Arphone Pei

ZWCAD Deputy Manager for Application R&D

View all posts

Add comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Our Blog

ZWCADZW3D

By using this form you agree to the storage and handling of your data by this website.