dcl_Grid_GetRowCount

Started by Basher, May 17, 2015, 11:16:41 PM

Previous topic - Next topic

Basher

i have 52,000 rows when i use "dcl_Grid_GetRowCount" , i got a negative count ???

Fred Tomke

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

roy_043

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

Then I'm wrong, sorry.
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Basher

whats can I do ?
Any Idea ...

Peter2

Quote from: Basher on May 18, 2015, 09:40:43 AM
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.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

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:
Code (autolisp) Select
(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.
Owen Wengerd (Outside The Box) / ManuSoft

roy_043

Quote from: owenwengerd on May 19, 2015, 08:11:37 PM
AutoLISP uses 16 bit integers natively
Then I must be missing something:
Code (autolisp) Select
(type 2147483647) => INT

owenwengerd

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.
Owen Wengerd (Outside The Box) / ManuSoft

roy_043

Thanks for that clarification Owen.

owenwengerd

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.
Owen Wengerd (Outside The Box) / ManuSoft