Since the and function uses short-circuit evaluation, your select1obj function may be reduced to:
(defun select1obj ( typ msg / ent )
(while
(and (setq ent (car (entsel msg)))
(not (wcmatch (cdr (assoc 0 (entget ent))) typ))
)
(princ "\nInvalid object selected, please try again.")
)
ent
)
This also allows the user to dismiss the prompt in order to exit the function (with the function returning nil), without having to force an error by pressing Esc.
You might also want to consider the following for a filtered single selection:
(ssget "_+.:E:S" '((0 . "LWPOLYLINE")))