The AutoCADET's Guide to Visual LISP: Optimize and Customize Your AutoCAD Design Environment

The scope of a symbol, or variable, is where it can be seen. If you change a given symbol, you most likely expect to retrieve it at a later time. Should that symbol no longer be available or have a value that has been changed due to another routine running, your program is suffering from a scope-related error.
Tracking the scope of a symbol in Visual LISP is simple. Symbols are defined as either local or global in relation to a function. A symbol is local if it appears in the parameter list of the function. If the symbol appears before a slash in the parameter list, it has an initial value supplied by the calling function. When the symbol appears after the slash, its initial value is NIL. A symbol is considered global otherwise.
A local symbol can be seen only inside the function and by functions called inside that function. After the function is finished, the symbol is no longer set to the value inside the function and reverts to the value it had before the function was called.
Table 3.2 summarizes the differences between global and local symbols as well as bound symbols.
| Variable type | Scope | Usage | Description |
|---|---|---|---|
| Global variable | Available everywhere in an application | Holds calculated values that might be useful elsewhere. | A symbol is global with respect to a function if it does not appear in the parameter list of the function. |
| Local variable | Available only... |