Message 1 of 4

Not applicable
07-02-2019
04:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How can I check if a variable is Null with AutoLISP? I have tried a dozen different methods and nothing seems to work for this simple script.
What I am trying to do is see if variable "a" has a value and if it does not then prompt the user to assign it. Here are some of the methods I have tried so far...
(defun c:ZOINK ()
(if (null (getvar a))
(if (null a))
(if (nil a))
(if (= a nil))
(if (/= a nil))
(if (= a null))
(if (/= a null))
(setq a (getreal "\nEnter a Number : ")
b (getreal "\nEnter Second Number : ")
)
)
)
Every single one returns with an AutoCAD message stating "AutoCAD variable setting rejected: "CMDECHO" nil". If I remove the conditional the script works as expected.
Solved! Go to Solution.