Author Topic: Very specific issue using DCL dialog causes ACAD to freeze every time...  (Read 1507 times)

0 Members and 1 Guest are viewing this topic.

Ben Clark

  • Newt
  • Posts: 94
So I'm moving items in a list up and down exactly like Lee Mac's tab sort program. I'm even using functions he wrote called lm:listdown and lm:listup.

http://www.lee-mac.com/tabsort.html
http://www.lee-mac.com/listboxfunctions.html

When I run my code and press a dcl button that moves an item in a list up one row, ACAD completely and irrecoverably freezes every time without fail.

This thread: https://www.theswamp.org/index.php?topic=9281.0 seems to indicate that using set_tile right after end_list would cause this. But I have no idea why and and I have no idea how to fix it.

any help is appreciated.




Code: [Select]

; moveup is called by a button to move an item up in a dcl listbox

(defun moveup (/ setindex nameslist nameslistnew)

(setq
setindex (atoi (get_tile "msnameslist"))
nameslist (vlax-ldata-get "msnames" "msnameslist")
nameslistnew (cadr (lm:listup (list setindex) nameslist))
)

(vlax-ldata-put "msnames" "msnameslist" nameslistnew)

(ms-listbox)

(set_tile "msnameslist" (rtos (- setindex 1)))
)


; This refreshes the dcl listbox

(defun ms-listbox (/ msnameslist)

(setq msnameslist (vlax-ldata-get "msnames" "msnameslist"))

(start_list "msnameslist")
  (mapcar 'add_list msnameslist)
  (end_list)
)



roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Very specific issue using DCL dialog causes ACAD to freeze every time...
« Reply #1 on: December 19, 2017, 05:19:53 PM »
What stands out is the use of rtos instead of itoa.
And it may be worth checking how AC responds if the index becomes negative.

Your use of ldata is peculiar: why don't you pass the list as an argument to the functions?

Ben Clark

  • Newt
  • Posts: 94
Re: Very specific issue using DCL dialog causes ACAD to freeze every time...
« Reply #2 on: December 20, 2017, 08:33:23 AM »
Thanks for the reply Roy.

You're absolutely right about the ldata thing. Not sure why I'm calling it in the refresh function when it was already called and could be passed as an argument.

Don't rtos and itoa do the same thing if passed an integer?



EDIT: Thanks, Roy. you just solved my problem. I switched to itoa and it fixed it... I just feel a little dum now.
« Last Edit: December 20, 2017, 08:41:30 AM by barnjart42 »

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Very specific issue using DCL dialog causes ACAD to freeze every time...
« Reply #3 on: December 20, 2017, 09:14:51 AM »
Don't rtos and itoa do the same thing if passed an integer?

Only if supplied with a units argument of 2 and a precision argument of 0 [e.g. (rtos <number> 2 0)], or with no arguments if LUNITS=2 and LUPREC=0.

Ben Clark

  • Newt
  • Posts: 94
Re: Very specific issue using DCL dialog causes ACAD to freeze every time...
« Reply #4 on: December 20, 2017, 01:48:24 PM »
Thanks, Lee. That clears that up.

And thanks for making those list functions public :). That helped me out a lot.