Vlisp Variables
Vlisp Variables
Ok, so this isn't a cure all for CAD, but all the other cheesy CAD blog names are taken....
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
Mistress of the Dorkness
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).
This was just a small example, but if you ever work on a large routine with dozens of variables, this
tip can really help.