Sure, you can always take the user input out of the function.
LYRFRMTXT only needs the txt variable, you can provide it as a parameter.
For example:
c:LM1 contains what I took away from LYRFRMTXT .
c:LM2 just permits you to hard code a layer
(defun c:LM2 ( / )
(LYRFRMTXT "Layer1")
)
(defun c:LM1 ( / o1 o1n txt)
(setq o1 (entget(car(entsel "\nPick descriptive Text object: "))))
(setq o1n (assoc 1 o1))
(setq txt (cdr o1n))
(LYRFRMTXT txt)
(princ)
)
(defun LYRFRMTXT ( txt / o2 o2n elist cntr)
(setvar "cmdecho" 0)
(princ "\nSelect entities for layer change: ")
(if (setq o2n (ssget))
(progn
(setq cntr 0)
(while (< cntr (sslength o2n))
(setq o2(ssname o2n cntr))
(setq elist(entget o2))
(setq elist(subst (cons 8 txt)(assoc 8 elist) elist))
(entmod elist)
(setq cntr(+ cntr 1))
)
)
(princ "\n select error")
)
)