[求助]求一比较大小的LISP
<p>图形中有文字“100”和“200”<br/>现在想对图形中文字进行判断</p><p>选取文字,如果文字大于50小于150,则此文字内容变成“A”<br/>如果文字大于150,则此文字内容变成“B”</p><p>请问如何把字符串“A”和“B”赋值到文字“100”和“200”中去?</p> (read "100")或(atoi "100"),即可与50或者150比较大小了。<br/> <p>能否按我的要求写个完整的LISP?<br/>XIEXIE</p> <p>(read "100")或(atoi "100"),即可与50或者150比较大小了</p><p>read 和 atoi 是不行的,假如数字为 50.2</p><p>用 atof 比较好</p><p>(defun c:tt (/ e a b)<br/> (while (setq e (car (entsel "\n选择文字: ")))<br/> (setq e (entget e)<br/> a (atof (cdr (assoc 1 e)))<br/> )<br/> (cond ((> 150 a 50)<br/> (setq b "A")<br/> )<br/> ((> a 150)<br/> (setq b "B")<br/> )<br/> )<br/> (entmod (subst (cons 1 b) (assoc 1 e) e))<br/> )<br/>)</p> 少个判断a<50,怎么处理,否则接着上次的b值更新 <p>少个判断a<50,怎么处理,否则接着上次的b值更新</p><p>此言极是</p><p>(defun c:tt (/ e a b)<br/> (while (setq e (car (entsel "\n选择文字: ")))<br/> (setq e (entget e)<br/> a (atof (cdr (assoc 1 e)))<br/> )<br/> (cond ((> 150 a 50)<br/> (setq b "A")<br/> )<br/> ((> a 150)<br/> (setq b "B")<br/> )</p><p> (T (setq b nil))<br/> )<br/> (if b (entmod (subst (cons 1 b) (assoc 1 e) e)))<br/> )<br/>)</p><p></p>
页:
[1]