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

Working with Symbols

You can create or define symbols in Visual LISP in two ways. One method defines a symbol that will hold data to be used by your program. The other method references your program function definition. Note that most LISP programmers use the term variable name instead of symbol.

Defining symbols with SET

To define a data-oriented symbol, you use the SET subr, which has two arguments: a symbol reference and a value. The SET subr stores the value in the computer, where it can be retrieved at a later time by using the symbol name. For example, the following LISP code sets the A symbol, or variable, to the value of integer 100.

(SET (QUOTE A) 100)

The QUOTE subr causes the evaluator to not evaluate the A symbol. This is what you want because you are putting data into A, not retrieving it. Instead of evaluating A, the expression uses the A symbol as an argument to the SET subr. The value 100, on the other hand, is evaluated and results in the value 100. This value is stored in the system using a reference symbol A.

Before you go any deeper into how symbols are stored and retrieved, you should learn a shorthand way of telling the evaluator, "Don't evaluate the symbol, use it." Instead of typing the QUOTE expression inside the SET expression, you can use the single quote mark, as in...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Robot Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.