写入大于32767的整数
如何使用lisp编写大于32767的文本整数。当我键入123456时,消息是“需要一个介于-32768和32767之间的整数” 使用getreal或getstring提示用户输入,测试输入的有效性,并将其转换为整数。
32767限制是AutoCAD早期版本中使用16位有符号整数的结果。 谢谢李。但我不明白这是我的代码怎么办?
(defun C:kk (/ input start rot count ang inc pt1)
(setq count (getint "Enter Starting No.: "))
(if (null count) (setq count 1))
(setq inc 1)
(setq th (getint "\nEnter text height: "))
(if (null th) (setq th 1.27))
;; set continue flag to True
(setq continue T)
(while continue
(setq input (getpoint (strcat "\nInsertion point for number")))
;; evaluate user input
(cond
(T
(command "text" "s" "Standard" "mc" input 2 0 count)
(setq pt1 input)
(setq count (+ count inc)))
)
)
(princ)
)
也许是这样?
(initget 5)
(setq lgint (fix (getreal "\nEnter value ")))
RK的解决方案很好-
或者,这里还有两个选项可以在提升16位限制的同时模拟标准getint函数的行为:
(defun mygetint ( msg / rtn )
(while
(and (setq rtn (getreal msg))
(not (equal rtn (setq rtn (atoi (rtos rtn 2 0))) 1e-)
)
(princ "\nRequires an integer value.")
)
rtn
)
(defun mygetint ( msg / rtn )
(while
(and (setq rtn (getstring msg))
(/='int (type (setq rtn (read rtn))))
)
(princ "\nRequires an integer value.")
)
rtn
)
(defun c:test ( )
(mygetint "\nEnter a number: ")
) 尊敬的RK&Lee,当我输入123456时,输出为-7616
奇怪的它在这里起作用。
_$ (initget 5)
nil
_$ (fix (getreal "\nEnter value "))<---- I entered "123456" at the command prompt.
123456
也许 吧:
(defun C:kk (/ input start rot count ang inc pt1)
;(setq count (getint "Enter Starting No.: "))
_$ (initget 5)
nil
_$ (setq count (fix (getreal "\nEnter value ")))
(if (null count) (setq count 1))
(setq inc 1)
(setq th (getint "\nEnter text height: "))
(if (null th) (setq th 1.27))
;; set continue flag to True
(setq continue T)
(while continue
(setq input (getpoint (strcat "\nInsertion point for number")))
;; evaluate user input
(cond
(T
(command "text" "s" "Standard" "mc" input 2 0 count)
(setq pt1 input)
(setq count (+ count inc)))
)
)
(princ)
)
你在运行什么操作系统?
页:
[1]