I'd probably approach it like so:
(defun c:foo (/ _getlength l s)
(defun _getlength (e / ep)
(if (vl-catch-all-error-p (setq ep (vl-catch-all-apply 'vlax-curve-getendparam (list e))))
0.
(vlax-curve-getdistatparam e ep)
)
)
(if (setq s (ssget "_X" '((0 . "~INSERT"))))
(foreach e (mapcar 'cadr (ssnamex s))
(if (> (- (setq l (_getlength e)) (fix l)) 0)
(entmod (append (entget e) '((62 . 1))))
)
)
)
(princ)
)