if (AutoLISP)

Conditionally evaluates expressions

Supported Platforms: Windows and Mac OS

Signature

(if testexpr thenexpr [elseexpr])
testexpr

Type: Integer, Real, String, List, Ename (entity name), T, or nil

Expression to be tested.

thenexpr

Type: Integer, Real, String, List, Ename (entity name), T, or nil

Expression evaluated if testexpr is not nil.

elseexpr

Type: Integer, Real, String, List, Ename (entity name), T, or nil

Expression evaluated if testexpr is nil.

Return Values

Type: Integer, Real, String, List, Ename (entity name), T, or nil

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

Examples

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

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

(if (= 2 (+ 3 4)) "YES!!")
nil