Started by Basher ·
2015-05-18 06:16 UTC ·
10 replies · SMF topic #2267
Basher
2015-05-18 06:16 UTC
i have 52,000 rows when i use "dcl_Grid_GetRowCount" , i got a negative count ???
fred_tomke
2015-05-18 13:06 UTC
Hi, I think it could be a limitation of lisp. I remember a borderline at nearly 32.000. The conversion from C++ to Lisp could lead in such a case.
Regards, Fred
roy_043
2015-05-18 13:58 UTC
It is my understanding that integers in AutoLisp are 32 bit. The maximum value is therefore 2147483647. According to the ODCL documentation the Row Count is a long (= 32 bit integer).
fred_tomke
2015-05-18 14:30 UTC
Then I'm wrong, sorry.
Fred
Basher
2015-05-18 16:40 UTC
whats can I do ?
Any Idea ...
Peter2
2015-05-19 16:44 UTC
author=Basher link=topic=2267.msg11402#msg11402 date=1431967243 wrote:
whats can I do ?
Any Idea ...
Usually Owen is happy if you deliver a more precise description of what you do / have, what you expect and what you get. And of course a code snippet, reduce to the topic, it the must helpful thing.
owenwengerd
2015-05-20 03:11 UTC
AutoLISP uses 16 bit integers natively, and therefore interprets the return value as a signed 16-bit integer. In some cases OpenDCL uses a floating point type when the value is too large to represent as a short integer, but I checked the code and in this case the row count is returned without any tricks. If you never have more than 65535 rows, you can use some trickery to convert it to an unsigned integer:
(cond ((minusp val) (+ (- val) 32768)) (val))
This trick won't work with more than 65535 rows because in that case the result would get truncated.
I will look at the code to see if it's feasible to return a real instead of an integer when the row count exceeds the capacity of an integer type.
roy_043
2015-05-20 07:47 UTC
author=owenwengerd link=topic=2267.msg11406#msg11406 date=1432091497 wrote:
AutoLISP uses 16 bit integers natively
Then I must be missing something:
(type 2147483647) => INT
owenwengerd
2015-05-20 12:07 UTC
Roy, I should have said that the ADS interface to AutoLISP uses 16 bit integers natively. I can't speak for AutoLISP internally. I do know that the ObjectARX documentation at one time explained that 32 bit integers could be passed between ADS applications only, and warned that passing a 32-bit integer back to AutoLISP would result in truncation to 16 bits. It's possible that AutoLISP has since been updated to use 32 bit integers internally, while the 16 bit ADS interface has never been updated. I did verify just now that returned integers are truncated to 16 bits.
roy_043
2015-05-20 12:31 UTC
Thanks for that clarification Owen.
owenwengerd
2015-05-21 17:20 UTC
It turns out that I had already added infrastructure to return 32-bit integers to AutoLISP, I just had to use it. I have now changed the grid methods and events for the next build of OpenDCL to pass row and column arguments as 32-bit integers.