在写一段程序,写完后发现文字中间如有空格程序执行还ok,如果前后有空格就不能算出来了,怎样让程序乎略掉前后的空格(文字中间的空格不能乎略) 下面是源程序和一个测试dwg档,求教大哥们开导一下,谢谢!(想搜索以前的相关贴子,搜索功能不好用,只能求教大家帮忙了) ;check_modifytxt (defun c:tt(/ ckent1 ckent2 txl ppa ppt pt ft fv con pkt txx txv ppc ccn cn cv stt ct cm txtv conn tu1 tu2) (setq m:err *error* *error* *merr*) (command "undo" "be") (defun *error*(msg) (if (and (not (wcmatch msg "*函数被取消")) (/= msg "quit / exit abort")) (princ (strcat "\n" msg)) ) (command "undo" "e") (setvar "cmdecho" 0) (setq *error* nil) (princ) ) (prompt "\nSelect text to comp and modify:") (SETQ Ppa(SSGET '((0 . "TEXT")))) (if ppa (progn (SETQ Ppt(ssadd)) (SETQ Ppc(ssadd) cm 0) (repeat (sslength ppa) (setq txtv (ssname ppa cm)) (if (>(strlen(cdr (assoc 1 (entget txtv))))8) (setq ppc(ssadd txtv ppc)) (setq ppt(ssadd txtv ppt)) ) (setq cm (1+ cm)) ) (while(> (sslength ppt) 0) (progn (setq ft(entget(ssname ppt 0))) (setq fv(assoc 1 ft)) (command "select" ppt "") (setq pkt(ssget "p" (list fv))) (setq txl(sslength pkt) tu1 0 txx txl) (repeat (- txx 1) (setq ckent1 (ssname pkt tu1) tu2 0) (repeat (- txx tu2 tu1 1) (setq ckent2 (ssname pkt (+ tu2 tu1 1))) (if (< (distance (cdr (assoc 10(entget ckent1))) (cdr (assoc 10(entget ckent2)))) 0.00001) (setq txl(1- txl)) ) (setq tu2(1+ tu2)) ) (setq tu1(1+ tu1)) ) ;(repeat (- txx 1) (setq conn 0) (repeat (sslength ppc) (setq ct(entget(ssname ppc conn))) (setq cv(cdr(assoc 1 ct)) cn 1 ccn 1) (while (and(< cn (strlen cv))(/=(substr cv cn 1)":")) (setq cn (1+ cn)) ) (while (and(< ccn (strlen cv))(/=(substr cv ccn 1)"-")) (setq ccn (1+ ccn)) ) (if (= (substr cv cn 1) ":") (progn (setq txv(strcat(cdr fv)":"(rtos txl 2 0)"-"(substr cv (1+ cn)(strlen cv)))) (if (= (substr cv ccn 1) "-") (setq txv(strcat (cdr fv)":"(rtos txl 2 0)"-"(substr cv(1+ ccn)(strlen cv)))) ) ) ) (if txv (if (and(= (substr txv 1 cn)(substr cv 1 cn))(< cn (strlen cv))) (if (/=(substr txv 1 ccn)(substr cv 1 ccn)) (progn (princ "\nText change:\t" ) (princ (strcat cv " --> " txv)) (setq stt (subst (cons 1 txv) (assoc 1 ct) ct)) (entmod stt) (entupd (ssname ppc conn)) ) ) ) ) (setq txv nil) (setq conn (1+ conn)) ) ;(repeat (sslength ppc) (setq con 0) (repeat (sslength pkt) (setq ppt(ssdel (ssname pkt con)ppt) con (1+ con)) ) ) ) ) ) (*error* "") ) |