Another way to write it:
(defun C:test ( / lin elst pt_str pt_end xPoint)
(setq lin (car (entsel "\nSelect Line: ")))
(setq elst (entget lin))
(setq pt_str (cdr (assoc 10 elst)))
(setq pt_end (cdr (assoc 11 elst)))
(setq xPoint (getpt pt_str pt_end))
)
(defun getpt (pt_str pt_end / done grr typ key vecs)
(princ "\nPick Point: ")
(while
(progn
(setq grr (grread 't 4 1) typ (car grr) key (cadr grr))
(if vecs (grvecs vecs))
(cond ((= typ 2) (if (or (= key 13) (= key 32)) (setq key nil) t))
((= typ 3) nil)
((= typ 5) [color=red](grvecs (setq vecs (list -256 pt_str key key pt_end)))[/color] t))
)
)
(if (= typ 3) key)
)
This works only if you use color -256 (or 256) for GRVECS, as Autolisp help says:
"AutoCAD colors are in the range 0–255. If the color value is greater than 255,
succeeding vectors are drawn in XOR ink, which complements anything it draws over
and which erases itself when overdrawn."
For any other color, better VovKa's solution. In this case you can avoid
(if vecs (grvecs vecs))
as it's not useful.