OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: Jim Short on April 25, 2015, 05:09:44 PM

Title: Stop lisp execution with modeless form close button
Post by: Jim Short on April 25, 2015, 05:09:44 PM
I have an animation running in a lisp expression. The expression tests a variable that stops execution when a button is pressed on a modeless dialog displayed during the animation.
;;cancel
(defun c:TahlCAM/RunSpeed/btClose#OnClicked   ()
  (setq >animate nil)
  (if (DCL_Form_IsActive TahlCAM/RunSpeed)
      (DCL_Form_Close TahlCAM/RunSpeed)
  )
)

This works as expected in Acad2004 but does not respond in Acad2010.
Can anyone suggest a solution?
To my knowledge there is only a difference in acad version and arx version.
Title: Re: Stop lisp execution with modeless form close button
Post by: owenwengerd on April 26, 2015, 09:20:00 AM
What exactly do you mean by "does not respond"? Is it because DCL_Form_IsActive is not returning what you expect?
Title: Re: Stop lisp execution with modeless form close button
Post by: Jim Short on April 26, 2015, 12:44:15 PM
The modeless form's titlebar has focus but is totally unresponsive to the mouse while routine is executing.

If the callback was being evaluated  (setq >animate nil) would occur.
This stops the animation and the routine continues the execution without it.

The OncCicked event works properly except when inside the lisp routine.
Acad2015 and Bricscadv15 both exhibit this behavior. Acad2004 works properly.
Title: Re: Stop lisp execution with modeless form close button
Post by: owenwengerd on April 26, 2015, 02:17:51 PM
Ok, I'm assuming that by "lisp animation" you mean a loop of some sort, correct? if so, then there needs to be something inside the loop that gives Windows a chance to process messages. There's no way to guess without seeing the code why it might be different in R2004, but you should probably put something inside the loop explicitly for giving AutoCAD a chance to catch up with input events while the loop runs. Maybe something as simple as (princ) or (grtext) would work.
Title: Re: Stop lisp execution with modeless form close button
Post by: Jim Short on April 26, 2015, 04:26:03 PM
I tried (princ) and (grtext). Only after pressing escape did the routine break. It broke near the (princ) which said you were on the right track. One additional detail. Bricscad crashes if I try to close without first closing the modeless form on left on the display.
Title: Re: Stop lisp execution with modeless form close button
Post by: owenwengerd on April 26, 2015, 10:03:43 PM
There might be undesirable command line side effects, but your animation would be much more efficient if you use the  event to update your animation instead of running it in a loop. (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Event/Timer.htm\OnTimer[/url)
Title: Re: Stop lisp execution with modeless form close button
Post by: Jim Short on April 29, 2015, 06:53:45 PM
Owen,
I played with the OnTimer and found that it waited till my routine was done. I am glad to find out you added that event.

I have been thinking of what you said about getting my routine out of the big loop for some time now.
Thanks for all your efforts.
Jim
Title: Re: Stop lisp execution with modeless form close button
Post by: owenwengerd on April 29, 2015, 07:55:10 PM
You're welcome, Jim. If OnTimer didn't work, then it sounds like you've still got something running in a loop that doesn't yield to allow message processing. The reason for using OnTimer is to eliminate the loop altogether.