OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Basher on May 17, 2015, 11:16:41 PM

Title: dcl_Grid_GetRowCount
Post by: Basher on May 17, 2015, 11:16:41 PM
i have 52,000 rows when i use "dcl_Grid_GetRowCount" , i got a negative count ???
Title: Re: dcl_Grid_GetRowCount
Post by: Fred Tomke on May 18, 2015, 06:06:03 AM
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
Title: Re: dcl_Grid_GetRowCount
Post by: roy_043 on May 18, 2015, 06:58:00 AM
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).
Title: Re: dcl_Grid_GetRowCount
Post by: Fred Tomke on May 18, 2015, 07:30:14 AM
Then I'm wrong, sorry.
Fred
Title: Re: dcl_Grid_GetRowCount
Post by: Basher on May 18, 2015, 09:40:43 AM
whats can I do ?
Any Idea ...
Title: Re: dcl_Grid_GetRowCount
Post by: Peter2 on May 19, 2015, 09:44:34 AM
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.
Title: Re: dcl_Grid_GetRowCount
Post by: owenwengerd on May 19, 2015, 08:11:37 PM
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.
Title: Re: dcl_Grid_GetRowCount
Post by: roy_043 on May 20, 2015, 12:47:28 AM
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
Title: Re: dcl_Grid_GetRowCount
Post by: owenwengerd on May 20, 2015, 05:07:52 AM
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.
Title: Re: dcl_Grid_GetRowCount
Post by: roy_043 on May 20, 2015, 05:31:34 AM
Thanks for that clarification Owen.
Title: Re: dcl_Grid_GetRowCount
Post by: owenwengerd on May 21, 2015, 10:20:59 AM
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.