Jump to content

Recommended Posts

Posted

How can i write a text integer more than 32767 using lisp.

when i type 123456 the message is "Requires an integer between -32768 and 32767"

Posted

Prompt for user input using getreal or getstring, test the validity of the input, and convert it to an integer.

 

The 32767 limit is a remnant of the use of 16-bit signed integers in early releases of AutoCAD.

Posted

Thanks Lee . But i am not getting this is my code what to do ?

(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)
)

Posted

Maybe something like this?

 

(initget 5)
(setq lgint (fix (getreal "\nEnter value ")))

Posted

RK's solution is good -

 

Alternatively, here are two more options to imitate the behaviour of the standard getint function whilst lifting the 16-bit limit:

(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: ")
)

Posted

Dear RK & Lee when i m giving input 123456 the output is -7616

Posted
Dear RK & Lee when i m giving input 123456 the output is -7616

 

Strange. It works here.

 

_$ (initget 5)
nil
_$ (fix (getreal "\nEnter value "))  <---- I entered "123456" at the command prompt.
123456

Posted

Dear RK It is not working. see my full code.


(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)
)

Posted

Maybe :

 

(setq count (fix (+ (float count) inc)))

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...