Stepping Through Code

AutoCAD Visual LISP

 
Stepping Through Code
 
 
 

There are three buttons you can use to step through your code. These are the three left-most icons on the Debug toolbar. In sequence, they represent the following actions:

  • Step in to the highlighted expression.
  • Step over to the end of the highlighted expression.
  • Step out to the end of the function where you are currently stopped.

Before you make a selection, take another look at the status of the highlighted code, the cursor position, and the Step Indicator button. In summary: an expression is highlighted, consisting of a getdist function nested within a setq function, and the cursor is positioned at the very beginning of the highlighted block.

To step through the code from the breakpoint

  1. Choose the Step Over button.

    After you choose the Step Over button, control passes to AutoCAD and you are prompted to specify the width of the path.

  2. Reply to the prompt.

    After you specify the width, control passes back to VLISP. Notice where your cursor is and what the step indicator button shows.

    VLISP evaluates the entire highlighted expression, then stops at the end of the expression.

  3. Choose the Step Over button again. VLISP jumps to the beginning of the next block of code, and highlights the entire block.
  4. Choose the Step Into (not Step Over) button.

NoteDuring this exercise, if you make an incorrect selection and skip a step or two, you can restart the exercise very easily. First, choose the Reset button from the Debug toolbar. This terminates the execution of any VLISP code, and resets the VLISP system to the top level. Next, start over at step 1.

Now the first cons function is highlighted, and VLISP is stopped right before the function (notice the Step Indicator button).