为什么一次只能替换一个
这是一个字符替换的程序,请问当文字里同时有多个要替换的字符时,为什么一次只能替换一个?(vl-load-com)
(defun c:tt (/ ss n ent obj txt i)
(if (setq ss (ssget '((0 . "*TEXT") )))
(repeat (setq n (sslength ss))
(setq ent (ssname ss (setq n (1- n))))
(setq obj (vlax-ename->vla-object ent))
(setq txt (vla-get-textstring obj))
(cond
((wcmatch txt "*a*")
(setq txt (ReplaceText "%%130" "a" txt))
)
((wcmatch txt "*d*")
(setq txt (ReplaceText "%%131" "d" txt))
)
((wcmatch txt "*f*")
(setq txt (ReplaceText "%%132" "f" txt))
)
((wcmatch txt "*A*")
(setq txt (ReplaceText "%%130" "A" txt))
)
((wcmatch txt "*D*")
(setq txt (ReplaceText "%%131" "D" txt))
)
((wcmatch txt "*F*")
(setq txt (ReplaceText "%%132" "F" txt))
)
)
(vla-put-textstring obj txt)
)
)
(princ)
)
(defun ReplaceText (NewStr oldstr string / txt)
(setq txt string)
(while (vl-string-search oldstr txt)
(setq txt (VL-STRING-SUBST NewStr oldstr txt))
)
txt
)
自己顶一个
页:
[1]