;;;Change a number in (m)any text string(s) by a value. ;;;Adds parenthesis around number. (uses UINT USTR) ;;;Specify or change precision (decimal places) too. ;;; ;;; ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 9-19-95 ;;;> EDITED: 02-12-1999 ;;; (DEFUN C:TPARNO (/ luprc tele elem tstr cnt_1 cnt_2 pfx_str sfx_str) (while (setq tele (nentsel "\nSelect TEXT for parenthesis ")) (setq elem (entget (car tele))) (setq tstr (strcat "(" (cdr (assoc 1 elem)) ")")) ;;; (setq cnt_1 1 ;;; cnt_2 1 ;;; ) ;_ end of setq ;;; (while (and ;;; (/= (substr tstr cnt_1 1) "0") ;;; (/= (substr tstr cnt_1 1) "1") ;;; (/= (substr tstr cnt_1 1) "2") ;;; (/= (substr tstr cnt_1 1) "3") ;;; (/= (substr tstr cnt_1 1) "4") ;;; (/= (substr tstr cnt_1 1) "5") ;;; (/= (substr tstr cnt_1 1) "6") ;;; (/= (substr tstr cnt_1 1) "7") ;;; (/= (substr tstr cnt_1 1) "8") ;;; (/= (substr tstr cnt_1 1) "9") ;;; (< cnt_1 (strlen tstr)) ;;; ) ;_ end of and ;;; (if (wcmatch (substr tstr cnt_1 5) "%%###") ;;; (setq cnt_1 (+ cnt_1 5)) ;;; (setq cnt_1 (1+ cnt_1)) ;;; ) ;;; ) ;_ end of while ;;; (while (and ;;; (or ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "0") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "1") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "2") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "3") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "4") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "5") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "6") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "7") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "8") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) "9") ;;; (= (substr tstr (+ cnt_1 cnt_2) 1) ".") ;;; ) ;_ end of or ;;; ) ;_ end of and ;;; (setq cnt_2 (1+ cnt_2)) ;;; ) ;_ end of while ;;; (if (> cnt_1 1) ;;; (progn ;;; (setq pfx_str (substr tstr 1 (1- cnt_1))) ;;; (if (>= (strlen tstr) (+ cnt_1 cnt_2)) ;;; (setq sfx_str (substr tstr (+ cnt_1 cnt_2))) ;;; (setq sfx_str "") ;;; ) ;_ end of if ;;; ) ;_ end of progn ;;; (progn ;;; (if (>= (strlen tstr) cnt_2) ;;; (setq sfx_str (substr tstr cnt_2)) ;;; (setq sfx_str "") ;;; ) ;_ end of if ;;; (setq pfx_str "") ;;; ) ;_ end of progn ;;; ) ;_ end of if ;;; (setq nstr ;;; (strcat ;;; (if (= (substr pfx_str (strlen pfx_str) 1) "(") ;;; (substr pfx_str 1 (1- (strlen pfx_str))) ;;; pfx_str ;;; ) ;_ end of if ;;; (if (= (substr pfx_str (strlen pfx_str) 1) "(") ;;; "" ;;; "(" ;;; ) ;_ end of if ;;; (substr tstr cnt_1 cnt_2) ;;; (if (= (substr sfx_str 1 1) ")") ;;; "" ;;; ")" ;;; ) ;_ end of if ;;; (if (= (substr sfx_str 1 1) ")") ;;; (substr sfx_str 2) ;;; sfx_str ;;; ) ;_ end of if ;;; ) ;_ end of strcat ;;; ) ;_ end of setq (setq elem (subst (cons 1 tstr) (assoc 1 elem) elem ) ;_ end of subst ) ;_ end of setq (entmod elem) (entupd (cdr (assoc -1 elem))) ) ;_ end of while ) ;_ end of DEFUN ;|«Visual LISP© Format Options» (72 2 40 2 T "end of " 60 9 0 0 0 T T nil T) ***Don't add text below the comment!***|;