Chapter 36. Exploring Advanced AutoLISP Topics
This chapter builds on the previous two chapters and introduces you to a few advanced AutoLISP topics, including local and global variables, ActiveX, and debugging.
Note
AutoCAD LT does not support AutoLISP, so this entire chapter is for AutoCAD only.
Understanding Local and Global Variables
In this section, you read how local and global variables are accessed within a function, as well as some common syntax. You also discover what can happen when global variables are not properly documented.
Chapter 35 explained that a variable is a symbolic name that can be operated on in a given program. An important part of using variables is being able to assign values to them. There are two types of variables, global and local.
A global variable is exposed, or available, to all AutoLISP functions that you've loaded into your drawing. A global variable retains its value after the program that defined it is finished. You use a global variable when you want its value to be available across an entire project, as opposed to just one function within a project. This allows you to retain a fixed value that might be used and assigned by different functions, or for debugging. Any variable that you don't specifically define as a local variable is a global variable.
A local variable is temporarily assigned a value during a function's execution. After the function completes executing, the local variable value is discarded. AutoLISP can now use the memory that was ...
Get AutoCAD® 2009 & AutoCAD LT® 2009 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.