Since your two selections are the same, you can abstract the process into a separate function, e.g.:
(defun c:astfilletmember ( / ent1 ent2 )
(if (and (setq ent1 (getmember "\nSelect 1st member: "))
(setq ent2 (getmember "\nSelect 2nd member: "))
)
(command "_AstM9CommTrimExtend" "" "S" ent1 "" ent2 "" ""
"_AstM9CommTrimExtend" "" "S" ent2 "" ent1 "" ""
)
)
(princ)
)
(defun getmember ( msg / ent )
(while
(progn
(setvar 'errno 0)
(setq ent (car (entsel msg)))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (null ent)
nil
)
( (/= "ASTBEAM" (cdr (assoc 0 (entget ent))))
(princ "\nThe selected object is not an ASTBEAM.")
)
)
)
)
ent
)
(princ)
I'm unsure how you wish to use initget in this program.