只需一步,快速开始
请问怎么判断文字内容是否是整数?
比如:
"1" 是
"2.2" 不是
"说明:" 不是
使用道具 举报
把我给说糊涂了
什么意思啊,你又明白了什么啊,说说吧
个人认为直接用type函数好像还是不能满足版主的要求,比如
(type "2")->str
版主希望得到的结果应该是int吧
但提供了一个很好的思路,我第一次用这个函数。。。呵呵
(type (read "2"))
(type (read "2.2"))
牛逼了~呵呵
caoyin发表于2010-1-25 13:19:00(type (read \"2\")) (type (read \"2.2\"))
正解
如果
(setq S nil)
則
(type (read S))
會產生錯誤
最好多加個判斷式, 為你寫好的源碼如下: (defun isInt(s) (if (and s (= (type (read s)) 'INT) ) 'T nil ) )
;;在AutoCAD2010通過測試;;(isInt (setq s nil)) RETURN nil;;(isInt "123") RETURN 'T;;(isInt "12.3") RETURN nil;;(isInt "ABC") RETURN nil
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 ) ©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途
GMT+8, 2025-9-25 11:03 , Processed in 0.155170 second(s), 28 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.