Try this re-written code.
The getkword options work on the initial letter, although the whole word is in the initget, as the initial letters are unique.
Select Prefix or Suffix - Default (return pressed = Suffix)
Enter Prefix or Suffix string
Select Option Text Attribute Exit - Default (return pressed = Text)
Text Option Selected - Item selection for text is by ssget, only Text and MText entities can be selected. Once right mouse is clicked or enter pressed the selected items are processed
Attribute Option Selected Item selection is by nentsel. Select Attribute and item is processed. It will then ask you to select another Attribute. This loop will continue until a null selection is made (select on blank area of drawing)
Exit Option Selected Quits Lisp
(defun c:PST (/ c_doc PreSuf str t_type ss ent obj)
(vl-load-com)
(setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
(initget "Prefix Suffix")
(setq PreSuf "Suffix"
PreSuf (getkword (strcat "\nChoose [Prefix/Suffix] < " PreSuf " > : "))
);end_setq
(if (not PreSuf) (setq PreSuf "Suffix"))
(while (not str)
(setq str (getstring T (strcat "\nEnter " PreSuf " String : ")))
(cond ( (< (strlen str) 1)
(princ "Null Input Try again")
(setq str nil)
)
);end_cond
);end_while
(while (/= t_type "Exit")
(initget "Text Attribute Exit")
(setq t_type "Text"
t_type (getkword (strcat "\nSelect Option [Text/Attribute/Exit] < " t_type " > : "))
);end_setq
(if (not t_type) (setq t_type "Text"))
(cond ( (= t_type "Text")
(prompt "\nSelect Text/MText Items : ")
(setq ss (ssget '((0 . "TEXT,MTEXT"))))
(vlax-for obj (vla-get-activeselectionset c_doc)
(cond ( (= PreSuf "Prefix")
(vlax-put-property obj 'textstring (strcat str (vlax-get-property obj 'textstring)))
)
( (= PreSuf "Suffix")
(vlax-put-property obj 'textstring (strcat (vlax-get-property obj 'textstring) str))
)
);end_cond
);end_for
(setq ss nil)
)
( (= t_type "Attribute")
(while (setq ent (nentsel "\Select Attribute to convert to Text : "))
(cond ( (= (cdr (assoc 0 (entget (car ent)))) "ATTRIB")
(setq obj (vlax-ename->vla-object (car ent)))
(cond ( (= PreSuf "Prefix")
(vlax-put-property obj 'textstring (strcat str (vlax-get-property obj 'textstring)))
)
( (= PreSuf "Suffix")
(vlax-put-property obj 'textstring (strcat (vlax-get-property obj 'textstring) str))
)
);end_cond
)
(
(alert "Not an Attribute \n\nYou MUST Select an Attribute")
)
);end_cond
);end_while
)
);end_cond
);end_while
(princ)
);end_defun
(princ)
I am not one of the robots you're looking for