Watching Variables As You Step Through a Program
 
 
 

While you step through your program, you can add variables to the Watch window and change their values.

If you do not see the Watch window, simply choose the Watch Window button on the toolbar to bring it back.

If your Watch window stills contains the variable gp_PathData, choose the Clear Window button displayed at the top of the Watch window.

To add variables to the Watch window

  1. Double-click on any occurrence of StartPt in the VLISP text editor window. This is the name of the variable whose value you want to track.
  2. Choose the Add Watch button in the Watch window, or right-click and choose Add Watch.
  3. Repeat this process for the variables EndPt and HalfWidth. Your Watch window should resemble the following:

If you are debugging a program that isn't working correctly, use breakpoints in combination with watches to make sure your variables contain the values you expect.

If a variable does not contain the value you think it should, you can change the value and see how it affects the program. For example, say that you expect the halfwidth value to be a whole number. But because you weren't careful about picking the points during the input selections, you ended up with a value like 1.94818.

To change the value of a variable while the program is running

  1. Enter the following at the Console prompt:
    (setq halfwidth 2.0)
    

    Note that the value in the Watch window changes. But can you be sure the new value will be used when the width sublist (40 . width) is created in the association list? Add one more expression to the Watch window to test this.

  2. Choose Debug Watch Last Evaluation from the VLISP menu.

    This adds a variable named *Last-Value* to your Watch window. *Last-Value* is a global variable in which VLISP automatically stores the value of the last expression evaluated.

  3. Step through the program (choosing either the Step Into or Step Over button) until the expression responsible for building the width sublist is evaluated. The code for this action is:
    (cons 40 (* HalfWidth 2.0))
    

    If you overrode the value of HalfWidth as specified, the evaluation of this expression should return (40 . 4.0) in the Watch window.