Are you only allowing the user one chance to select the objects? As Owen mentioned.
(setq ss (ssget ":S"))
if so then this is valid (= (getvar "ERRNO") 52) for ENTER only without an attempted selection.
An attempted selection returns 0
So you could put this in a loop if you need more than one attempt at a selection.
Thank you for this answer, it is helpful for me too!
I hope that this code is useful also for other:
(defun c:test (/ var snapcorr ss next)
;*************************************
(setq var (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq snapcorr (getvar "OSMODE"))
(setvar "OSMODE" 0)
;*************************************
(princ "\nSelect: ")
(setq ss (ssget ":S"))
(setq next T)
(while (= next T)
(progn
(if ss
(if (= (sslength ss) 1)
(progn
(alert "I have selected only an object, then I continue again.")
(setq ss (ssget ":S"))
)
(progn
(alert "I have selected more object, then I continue again")
(setq ss (ssget ":S"))
)
)
(progn
(if (/= (getvar "ERRNO") 52)
(progn
(alert "I don't have selected any objects, then I continue again")
(setq ss (ssget ":S"))
)
(progn
(alert "I have press Enter, then END")
(setq next nil)
)
)
)
)
)
)
;*************************************
(setvar "OSMODE" snapcorr)
(setvar "cmdecho" var)
(princ)
;*************************************
)