@jlaidle1 wrote:
.... the LSP would stop searching after the user selects 'cancel'.
That sounds to me like you don't necessarily want to find a whole selection set of such objects and select/highlight/grip them all, but rather want to step through, Zooming to each qualifying object, and exit once you arrive at the one you're looking for. If so, try this [very lightly tested]:
(defun C:FT ; = Find Text and step through looking at each
(/ *error* txtstr txtss n txtent)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(if txtent (redraw txtent 4)); in case of ESC to exit
(princ)
); defun - *error*
(setq txtstr (getstring T "\Text content to find {entire or partial, case-sensitive}: "))
(if (setq txtss (ssget "_X" (list (cons 1 (strcat "*" txtstr "*")) (cons 410 (getvar 'ctab)))))
(repeat (setq n (sslength txtss)); then
(command
"_.zoom" "_object" (setq txtent (ssname txtss (setq n (1- n)))) ""
"_.zoom" "0.5X" ; back off view for context [EDIT ratio as desired]
); command
(redraw txtent 3); highlight
(initget "eXit")
(if
(or
(= n 0); got to last one -- don't ask about next-or-Exit
(= (getkword "Press Enter/space to Zoom to next, or [eXit] <next>: ") "eXit")
); or
(progn (redraw txtent 4) (quit))
); if
(redraw txtent 4); un-highlight
); repeat
(prompt "\nNothing found containing that string."); else
); if
(princ)
); defun
It highlights the one it has Zoomed around, in case that makes it easier to notice, but it will also be smack in the center of the screen. When it gets to the one you want, you can eXit the routine either by choosing that option or by hitting ESCape. It leaves you Zoomed around that object [and un-highlights it], and likewise when it gets to the last one it found, if you haven't exited by then.
[Yes, it has the same shortcoming of not accounting for long Mtext with content in multiple 3-code entries, nor does it see Attributes as FIND can, but see whether it does what you want otherwise.]
Kent Cooper, AIA