szx025 发表于 2014-6-19 10:25:02

如何让数值保留小数点后两位

(setq str (getstring "\n请输入梯高<35>:"))
          (if        (= str "")
                (setq str "T2B07a-35")
                (setq str (strcat "T2B07a-" str))
          )
          (command "text" "j" "c" "non" p1 300 0 str)
如何让str的值保留小数点后两位。比如我输入40,或40.1,最后让生成的结果为T2B07a-40.00或T2B07a-40.10


自贡黄明儒 发表于 2014-6-19 10:33:25

http://bbs.mjtd.com/thread-108124-1-1.html

szx025 发表于 2014-6-19 17:29:03

黄大侠,我水平有限,没看懂你的程序,可以再详细说明一下吗

edata 发表于 2014-6-19 21:08:08

(setq bak_dimzin(getvar 'dimzin))
(setvar 'dimzin 0)
(setq str (getreal "\n请输入梯高<35>:"))
            (if str
              (setq str (strcat "T2B07a-" (rtos str 0 2)))
              (setq str "T2B07a-35")
            )
(and bak_dimzin (setvar 'dimzin bak_dimzin))
            (command "text" "j" "c" "non" p1 300 0 str)
页: [1]
查看完整版本: 如何让数值保留小数点后两位