You could do it this way:
Code:
(if (wcmatch (cdr (assoc 0 (setq e (entget (setq en (ssname p l)))))) "TEXT,MTEXT")
;; Continue reading and/or modifying the text's dxf data
Another alternative is to filter the selection set so it can only select Text or MText. Something like this:
Code:
(setq p (ssget '((0 . "TEXT,MTEXT"))))
Consider though that your routine might fail if the user selects nothing. The sslength call will error since p=nil instead of a selection set. You might want to combine those 3 user inputs in an and block and only continue running your code if all three was input by the user. To go further, perhaps something like this:
Code:
(if (and (setq p (ssget '((0 . "TEXT,MTEXT"))))
(setq corr (getreal "\nEnter correction: "))
(or (setq dec (getint "\nEnter decimal precision to maintain<2>: ")) (setq dec 2)))
(progn (setq l 0
n (sslength p)
count 0
count1 0)
(while (< l n)
;;; continued
If something differs in the dxf codes between TEXT & MTEXT (say something like width), then you can use the if statement as previous. Or even more useful might be cond, since then it's much simpler to extend later for other entity types as well. The idea is as follows:
Code:
(cond ((eq (cdr (assoc 0 (setq e (entget (setq en (ssname p l)))))) "TEXT")
;; Do whatever for only TEXT
)
((eq (cdr (assoc 0 e)) "MTEXT")
;; Do whatever for only MTEXT
;; Notice you don't need progn if you've got more than one statement
)
(t ;This is like the Else portion of an if,
;it's not needed but I'm sowing it for completeness
;; Do something else if none of the above
))