if

AutoCad AutoLISP Functions

 
if
 
 
 

Conditionally evaluates expressions

(if testexpr thenexpr [elseexpr]) 

Arguments

testexpr

Expression to be tested.

thenexpr

Expression evaluated if testexpr is not nil.

elseexpr

Expression evaluated if testexpr is nil.

Return Values

The if function returns the value of the selected expression. If elseexpr is missing and testexpr is nil, then it returns nil.

Examples

Command: (if (= 1 3) "YES!!" "no.")

"no."

Command: (if (= 2 (+ 1 1)) "YES!!")

"YES!!"

Command: (if (= 2 (+ 3 4)) "YES!!")

nil

See Also