GstarCAD 2024 LISP Debugger Guide

Contents

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/0607e6be71bd3aa838f0091a

1. Visual Studio Code

1.1. Install Visual Studio Code (VS Code)

Visual Studio Code (VS Code) is a free cross-platform source code editor developed by Microsoft® . The software supports functions such as syntax highlighting, intelligent code completion, code refactoring, and viewing definitions, and has built-in command-line tools and Git version control system.

With the functions provided by VS Code, it is possible to debug the program code in GstarCAD. Enter ' VLIDE ' or ' VLISP ' at the command line of GstarCAD to call up VS Code. If VS Code is not installed, the following message

appears:

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/cb09c929873380ffa17ccffa

Click the link https://code.visualstudio.com/ in the above window or visit the official website of VS Code directly to download and install VS Code.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/8e865d53fae25cb2a2ad547c

PDF page 3 — additional source text

Click the link https://code.visualstudio.com/ in the above window or visit the official website of VS Code directly

As an example, the following shows the process of installing VS Code for Windows after download.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/bcb934e74ad602278186e806 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/dbe5f17daef810217bd537af Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/994dcb4d40815e7899c57c57 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/f37bfab19647cc3223dd2809 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/ed684b105695533e6a9c7c5f Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/b425715cc0044ed7a7ce22b3

1.2. Install GstarLisp Plug-in

When starting VS Code through GstarCAD, GstarLisp plug-in is automatically installed by default. If there is a new version of GstarLisp , it will be automatically updated next time when starting VS Code through GstarCAD.

GstarLisp plug-in can also be installed manually. In this case search ' GstarCAD' , ' CAD ' or " LISP " in the VS Code application store, select ' GstarLisp ' and click to install.

After the plug-in is installed successfully, the icon of the GstarLisp is displayed in the activity bar. Details of GstarLisp , including name, introduction, features, new functions, installation, user guide, license information, change log, etc. can also be viewed as shown below.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/6e889219850ac60a68d04312

1.3. Visual Studio Code (VS Code) User Interface

After VS Code and GstarLisp plug-in are installed, input ' VLIDE ' or ' VLISP ' at the GstarCAD command line to start VS Code.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/8239b2f7f779b6153b152806

The following screenshot shows the user interface of VS Code. To learn more details about the user interface please visit the official website of VS Code at:

https://code.visualstudio.com/docs/getstarted/userinterface

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/c013c03b37c5fecdafbc874f
  • Activity Bar (A) : Located on the far left side. Allows switching between views, debugging and installing plug-ins, etc.

  • Side Bar (B) : Containing different views (like the Explorer) to assist working on projects.

  • Editor (C) : Working area for editing files. Possible to open multiple editors vertically and horizontally alongside.

  • Minimap (D) : Code outline that appears on the right side of the editor. Possible to click or drag the shaded area to quickly jump to different sections of the file being edited.

  • Panels (E) : Different panels displayed below the editor area for output or debug information, errors and warnings, or an integrated terminal.

  • Status Bar (F) : Information about the opened project and the files being edited.

2. File

2.1. Open File

Click the icon of GstarLisp to enter the view. Click Open Folder icon, select the directory to load and the .lsp

and .dcl files are filtered out and listed.

  • Click the file(s) in the list to be opened in the editor area on the right.

  • Click the Refresh to reload the selected directory file(s) if needed.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/1d9a01abd561fbcd271b9b3d

2.2. Edit File

The opened file(s) can be edited with rich editing functions provided by GstarLisp , such as:

  • Syntax highlighting

  • Smart hints

  • Automatic code completion/Code fragment

  • Parenthesis matching

  • Code folding

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/833857824a3e9f3dedc343df
  1. Debugging
  • 3.1. Debug Mode

  • 3.1.1. Add Configuration

GstarLisp provides two debug modes: Attach mode and Launch mode

  • Attach Mode: Attach a debug process to a running CAD process.

  • Launch Mode: Start a new CAD process by specifying the absolute path of the CAD running file.

The debug mode can be customized by editing the ' launch.json ' file, following steps below:

  1. Click create a ' launch.json' file .
Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/b5f42434a5d6177d97f8803f
  1. Select a debug mode, GstarLisp-Attach or GstarLisp-Launch , and add it to 'launch.json ' file.
Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/b0adcc9024a7e8825d91ca47
  1. Click Add Configuration to add another debug mode to ' launch.json ' file.
Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/787efa8fb1fc297dd1ca0c00
  1. Save the modifications to ' launch.json ' file.
Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/efef6f15415cc2db1856ef5f
  1. With the above configuration, it's possible to switch between the two modes during debugging.
Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/e06a73f2a44cdad4fe048546

3.1.2. Attach Mode

If Attach mode ( GstarLisp-Attach ) is selected, attachable CAD process need to be selected from the list in the debug window, as shown below, and then click Run to start debugging.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/666ce9fb45e640eb2a602b10

This debug mode is not able to be used if no attachable CAD process is selected. VS Code pops up the following

message and prompts to change the configuration of ' launch.json ' file or open the CAD.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/f691acc9de6e9ae4e4017dd8

3.1.3. Launch Mode

If Launch mode ( GstarLisp-Launch ) is selected, the absolute path of CAD running file (path format: e.g. ' C:\Program files\Gstarsoft\GstarCAD2022\gcad.exe ') needs to be specified in the extension settings of GstarLisp ,

as shown below. After the setting is completed, click Run to start a new CAD process for debugging.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/f030b5670cc633749a581518

If the absolute path of CAD running file is not specified, a message is displayed in the debug window to prompt specifying the path.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/377d4810ddd96c2c34c55528 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/f5280fbace04c97ab0adbc06

If there is already a running CAD process on the specified path, the following message is displayed when debugging (early versions of VS Code (before 1.57.1) do not have this function). Select Yes to start another GstarCAD instance, or select Cancel to close the window.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/237c87f478adc73d647efeb1

3.2. Side Bar

3.2.1. Variable

Locals : Display variable values of the executed code by hovering over their source in the editor. Last Value : Display the latest value variable.

NOTE
  • When the breakpoint is hit for the first time, the value of Last Value is not displayed.

  • In GstarLisp , Last Value displays the latest value of variable while AutoLisp displays the latest value/result of variable/expression.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/e744934c187b48fd06f4bf8f

3.2.2. Watch

Watch the real-time value change of specified variables and expressions.

Add the variables or expressions to the watching list by clicking button. When debugging, the values of variables and expressions in the watching list are real-time updated and displayed.

To remove variables or expressions from watching list please click button.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/c9403f071938612178c76551 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/7c5603afffb3466ca45d4383 Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/380eb95e28612a091f5392e4

It is also possible to add, edit and remove an expression from context menu by right-clicking WATCH .

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/02fa743c9150dec929798c3f

3.2.3. Call Stack

In GstarLisp , CALL STACK mainly displays the names of the called functions. It is possible to jump to the line where a function is located by double-clicking the function name.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/5a8b6f78cc298558f350604d

3.2.4. Breakpoint

When the program runs to the line where a breakpoint is located, it will be interrupted (NOTE: When the program is interrupted, the line where the breakpoint is located is not run yet).

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/090f94620a10314021f28240
  1. Set breakpoint: select the line of code where a breakpoint is set
  • In the left area, click line number to set a breakpoint, click again to cancel the breakpoint.

  • In the left area, right-click and select Add Breakpoint from the pop menu.

  • Press F9 to set a breakpoint, press F9 again to cancel the breakpoint.

  1. Delete/disable breakpoint:
  • Right-click the active breakpoint and select Delete Breakpoint or Disable Breakpoint from the pop menu.

  • Click to delete or disable the breakpoints at the side bar.

  • Delete all breakpoints at the side bar.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/35f83576c3065a8d29788c9d

3.3. Debug Console

Variables or expressions to be evaluated can be entered below the console.

  • When inputting a variable or an expression that exists in the code, the value of the variable or expression is displayed.

  • If the input variable or expression does not exist, the name of input variable or expression is displayed. In addition, debug console also displays log information to help locate problems.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/1923fdfe8f2cfd1fd32f9dc4

3.4. Debug Toolbar

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/f1a3cb02bca46bcca46a9219

3.4.1. Play/Continue

Play/Continue/(F5) : Jump to the next breakpoint.

3.4.2. Step Over

Step Over (F10) : Execute the current line of code and jump to the next line. It does not stop even the current line contains a function call (execute the whole sub-function as a step).

In GstarLisp , press F10 to execute the line and jump to the next line, while in AutoLisp , press F10 to execute the

line, and then press F10 again to jump to the next line.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/4865ec6a0f0d894803821b33

3.4.3. Step In

Step In (F11) : Step through the line of code. If the current line contains a function call, execute the first line of the

called function (enter the sub-function and continue stepping in).

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/a5a1cc50530befb677e4e094

3.4.4. Step Out

Step Out (Shift+F11) : When stepping in a sub-function and stepping out, execute the unexecuted section of the function.

3.4.5. Restart

Restart (Ctrl+Shift+F5)

Under Attach Mode: Restart current debugging without ending the current CAD process.

Under Launch Mode: Terminate the current debugging, end the current CAD process (without asking whether to

save the drawing) and restart a new CAD process for debugging.

3.4.6. Stop/Disconnect

Stop/Disconnect (Shift+F5):

Under Attach Mode: Stop the current debugging without ending the current CAD process.

Under Launch Mode: Stop the current debugging, and end the current CAD process (without asking whether to save the drawing).

Copyright reserved: Gstarsoft Co.,Ltd

Copying and referencing any part of this document is allowed. No part of this document may be changed without permission. Please keep this statement when copying or referencing this document.

Literature/GSTARCAD/2024/03 API Guides/assets/LISP Debugger Guide assets/d6a0382ab01b4c932ffad92e