CAD PANACEA HAS MOVED TO http://cadpanacea.com
24 July 2006
Vlisp variables          
Here is a tip on how to find all the variables in your lisp file. You can use this tip on existing lisp functions or on new ones you are writing.

Normally when you are in the middle of writing a routine, you may not take the time to declare local variables as you add them to your code. In fact, if you are testing and debugging you may want the variables to remain global. When you are ready though, there is an easy way to gather up all the variables used in a function.

First, lets look at an existing function in the Visual Lisp Editor (VLIDE).
[Note: this sample code was taken from the Visual Lisp help file]



Right after the defun statement, there are two parenthesis. These parenthesis are used to contain arguments and local variables. An empty set are still required even when you don't have either item.

In the VLIDE, go to the Tools menu, then choose Environment Options, then General Options. Switch to the Diagnostic tab and make sure that "Report statistics during syntax checking" is toggled ON.



Close this dialog. Make sure the window with your code is current in the VLIDE. Now look for the "Tools" toolbar. Click on the third icon from the left (this should be "Check Edit Window").



After you click this button, the Build Window will appear in the VLIDE. In this window will be a list of all global variables.



Copy this list of variables, along with the parenthesis, to your code window overwriting the single pair of parenthesis shown earlier. Add the required "/" character after the first parenthesis and then add a space after it. (The "/" character separates function arguments from local variables).

The result is shown here.



This was just a small example, but if you ever work on a large routine with dozens of variables, this tip can really help.

Labels:


PermaLink       Posted 7/24/2006 06:13:00 PM     
2 COMMENTS!


Comment from: Anonymous Anonymous
Date: August 7, 2006 at 12:55:00 PM CDT  

I just tried this on some code of mine and it decided to include :vlax-true from the following bit of code:

(= :vlax-true (vla-get-IsXRef item))

So, did I miss something or did VLIDE?

Josh


Comment from: Anonymous Anonymous
Date: August 24, 2006 at 9:03:00 PM CDT  

Very good tip, I did a spanish translation. Can I post this to a CAD forum?

Saludos
Marco Jacinto

mcoan001arrobahotmaildotcom

Post a comment