O'Reilly logo

AutoCAD® 2008 and AutoCAD LT® 2008 Bible by Ellen Finkelstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 36. Exploring Advanced AutoLISP Topics

IN THIS CHAPTER

  • Understanding local and global variables

  • Working with Visual LISP ActiveX functions

  • Debugging code

  • Using the Error Trace window

  • Using the Watch window

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, and 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required