latest version broke my code

Started by andrew.nao1, August 21, 2012, 06:31:42 AM

Previous topic - Next topic

andrew.nao1

I upgraded to the latest version 7.0.0.6 from 7.0.0.2

in my projects i have set a listbox to double click and it puts the text from the list box into acad. this worked with 7.0.0.2 but i get
; error: bad argument type: stringp
with the new version

attached are copies of my project with associated txt file
this is only 1 of 2 projects so far that i have found with this issue.




roy_043

On line 212 you have this code:
Code (autolisp) Select
(setq strStockBookNumber (substr (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1) 1 21))

Since (dcl_ListBox_GetSelectedItems) returns a list of strings this should be:
Code (autolisp) Select
(setq strStockBookNumber (substr (car (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1)) 1 21))

owenwengerd

It was a bug in earlier versions that GetSelectedItems did not return a list for a single-selection listbox. It should now match the documentation by always returning a list.
Owen Wengerd (Outside The Box) / ManuSoft

andrew.nao1

Quote from: owenwengerd on August 21, 2012, 08:20:34 AM
It was a bug in earlier versions that GetSelectedItems did not return a list for a single-selection listbox. It should now match the documentation by always returning a list.

i dont understand what this means


andrew.nao1

Quote from: roy_043 on August 21, 2012, 07:43:11 AM
On line 212 you have this code:
Code (autolisp) Select
(setq strStockBookNumber (substr (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1) 1 21))

Since (dcl_ListBox_GetSelectedItems) returns a list of strings this should be:
Code (autolisp) Select
(setq strStockBookNumber (substr (car (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1)) 1 21))

by doing what you listed returns an error
; error: bad argument type: consp

roy_043

Are you perhaps testing with 7.0.0.6 *AND* 7.0.0.2?
If you want your code to work with both versions you could try something like this:

Code (autolisp) Select
(setq tmp (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1))
(if (listp tmp) (setq tmp (car tmp)))
(setq strStockBookNumber (substr tmp 1 21))