setq

AutoCad AutoLISP Functions

 
setq
 
 
 

Sets the value of a symbol or symbols to associated expressions

(setq sym expr [sym expr]...) 

This is the basic assignment function in AutoLISP. The setq function can assign multiple symbols in one call to the function.

Arguments

sym

A symbol. This argument is not evaluated.

expr

An expression.

Return Values

The result of the last expr evaluated.

Examples

The following function call sets variable a to 5.0:

Command: (setq a 5.0)

5.0

Whenever a is evaluated, it returns the real number 5.0.

The following command sets two variables, b and c:

Command: (setq b 123 c 4.7)

4.7

setq returns the value of the last variable set.

In the following example, s is set to a string:

Command: (setq s "it")

"it"

The following example assigns a list to x:

Command: (setq x '(a b))

(A B)

See Also