本帖最后由 qazxswk 于 2024-6-22 19:32 编辑
我自己想到一个方案,抛砖引玉,我本想通过这个代码,引入到一些需要输入数据的插件中,如拉伸、移动、偏移。希望大家提提建议。
现在,如果输入500*2,后面结果会得到1000。
- (defun c:tt(/ com n txt1 txt2 zhi)
- (setq com (getstring "\n输入数据:"))
- (if (or
- (if (setq n (vl-string-search "+" com))
- (progn
- (setq txt1 (substr com 1 n))
- (setq txt2 (substr com (+ n 2)))
- (setq zhi (+ (atof txt1) (atof txt2)))
- ))
- (if (setq n (vl-string-search "-" com))
- (progn
- (setq txt1 (substr com 1 n))
- (setq txt2 (substr com (+ n 2)))
- (setq zhi (- (atof txt1) (atof txt2)))
- ))
- (if (setq n (vl-string-search "*" com))
- (progn
- (setq txt1 (substr com 1 n))
- (setq txt2 (substr com (+ n 2)))
- (setq zhi (* (atof txt1) (atof txt2)))
- ))
- (if (setq n (vl-string-search "/" com))
- (progn
- (setq txt1 (substr com 1 n))
- (setq txt2 (substr com (+ n 2)))
- (setq zhi (/ (atof txt1) (atof txt2)))
- )))
- (princ (strcat "\n运算结果为:"(rtos zhi)))
- (princ (strcat "\n输入数值为:"com))
- )
- (princ))
|