View Full Version : How do you return a decimal from dcl
Lions60
2006-12-08, 04:23 PM
I have some code and alot of my inputs into the dialogue box are decimals, but when the object is drawn the deciamals are rounded off. How do i get the decimal value and have the part drawn at the decimal. Hope i make some sense.
Lions60
2006-12-08, 07:30 PM
I tried changing all ATOI to ATOF and it would work fine once, but when you try and recall the program is would always have an error. The error was that it could not recognize decimals.
Are they rounded off to the nearest whole, or to 4 decimal places??? If it is the latter, you may want to change your units...Check that out and see if that helps...
abdulhuck
2006-12-10, 11:32 AM
but when the object is drawn the deciamals are rounded off.
You may try the system variable Luprec. (setvar "luprec" 4)
Lions60
2006-12-11, 01:58 PM
I changed the system variable luprec and still it rounds to a whole number. If my input is 13.875 it rounds to 13. No mattter what the decimal is it seems to only recongnize the whole number and that is what it stores.
kpblc2000
2006-12-11, 02:07 PM
Perpahs this could helps?
_$ (setvar "luprec" 0)
0
_$ (rtos 13.875)
"14"
_$ (rtos 13.875 2)
"14"
_$ (rtos 13.875 2 4)
"13.875"
_$ (rtos 13.875 2 3)
"13.875"
_$ (rtos 13.875 2 2)
"13.88"
_$ (rtos 13.875 2 1)
"13.9"
_$ (rtos 13.875 2 0)
"14"
_$ (rtos 13.875 2 10)
"13.875"
_$
Lions60
2006-12-11, 03:30 PM
I also tried using the rtos command. In the dialog box it does show that decimal values would be accepted (0.0000) but when the value is stored it rounds to the whole numbe still. Where i am setting my variables to what was entered in the dialogue box i also put the rtos, but doesn't seem to matter.
kpblc2000
2006-12-11, 03:38 PM
hmmm... Try to replace (atoi) function to (atof) function. Does it works like you expect?
Lions60
2006-12-11, 03:46 PM
I have tried using the atof function but the program just wont run using it. The program does almost everything i want except when i enter a decimal number that means i want a certain part of the drawing to be drawn at a decimal length and currently its not doing that. Other than that everything is working as expected
Lions60
2006-12-11, 04:09 PM
OK, i finally got it. It took a combination of atoi and atof along with rtos. Certain things had to be set to rtos and atof while some of my other variables needed to be atoi.
Terry Cadd
2006-12-11, 11:26 PM
I looked at your code early this morning, but wasn't able to debug it till after work. Here are a few things that you probably have already fixed. One thing I thought might help you place the previous values back in the edit boxes when you run it again, is to store the global decimal values as strings as they were initially entered by the user. This way you do not need to reuse the rtos function over and over again, which can reduce the accuracy.
(set_tile "cht" (rtos data_cht 2 4))
(set_tile "cwd" (rtos data_cwd 2 4))
(set_tile "pht" (rtos data_pht 2 4))
~~~~~~~~
(defun get:dcl_coilt ()
(setq data_cht (atof (get_tile "cht"))
data_cwd (atof (get_tile "cwd"))
data_pht (atof (get_tile "pht"))
~~~~~~~~
(command "circle" cir3 "d" "2.5")
Note: On the circle commands leave off the last "", to avoid the * unknown command echos.
Terry Cadd
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.