latest version broke my code

Started by andrew.nao1 · 2012-08-21 13:31 UTC · 5 replies · SMF topic #1869

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.



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

Since (dcl_ListBox_GetSelectedItems) returns a list of strings this should be:
(setq strStockBookNumber (substr (car (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1)) 1 21))
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.
author=owenwengerd link=topic=1869.msg9179#msg9179 date=1345562434 wrote:
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

author=roy_043 link=topic=1869.msg9175#msg9175 date=1345560191 wrote:
On line 212 you have this code:
(setq strStockBookNumber (substr (dcl_ListBox_GetSelectedItems oSTKBK_Form1_ListBox1) 1 21))

Since (dcl_ListBox_GetSelectedItems) returns a list of strings this should be:
(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
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:

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