Okay, well here's my version, with some explanation(I hope).
;;; this program prompts the user to select either dtext or mtext
;;; then extracts the layer name and text style name from the
;;; selected entity it then sets the current layer (clayer) and
;;; text style (textstyle) variables to reflect that of the selected
;;; entity
;;; version 1.0 Tue Jun 15, 2004 15:42:40
;;; Mark S. Thomas (mark_at_theswamp.org)
;;;
(defun c:slt (/ ent entlst lay sty)
;; the first thing we do is make sure the user selects something
;; the following line 1 returns T if something was selected
;; and nil if not. So line 1 is our test and line 2 is our
;; action(expression), or what to do if the test is T. As you can
;; see there is no action if the test is nil. We really don't care,
;; do we?
(if (setq ent (car (entsel "\nSelect (M)TEXT: "))); [1]
(setq entlst (entget ent)); [2]
)
;; line 3 is a test, it wants to know if 'entlst' is T or nil
;; if it's T we move down into another test 4. Here we make sure
;; what the user selected was in fact (M)Text. Our test has two
;; arguments this time, one is "is the entity TEXT?" and two is
;; "is the entity MTEXT?". 'or' will return T if either test is T,
;; otherwise 'or' returns nil. Because 'if' can only do two things
;; we add a 'progn' (line 5) in order to do all the actions we want
;; if our test (4) is T. Lines 6 and 7 we extract layer and text
;; style from the selected entity, 8 and 9 we set the acad variables
;; to reflect that of our entity. Note we do nothing if either of
;; our tests are nil. We could add (and probably should) a prompt
;; to our second 'if' statement to let the user know they selected
;; something that was *not* (M)TEXT.
(if entlst ;[3]
(if ;[4]
(or (= (cdr (assoc 0 entlst)) "TEXT"); [one]
(= (cdr (assoc 0 entlst)) "MTEXT"); [two]
)
(progn ;[5]
(setq lay (cdr (assoc 8 entlst)); [6]
sty (cdr (assoc 7 entlst)); [7]
)
(setvar 'clayer lay); [8]
(setvar 'textstyle sty); [9]
); progn
;; lets add an *else* clause to the second 'if' this
;; will be the action(expression) if our tests (one, two)
;; are nil. Lets use 'alert' to really get in the users
;; face if they select say, an attribute.
(alert "The entity you select was **NOT** (M)TEXT, please re-run the program")
); 2nd if
); 1st if
(princ)
)