Unexpected loop when executing function (returns to DCL)

Started by LauReis, May 21, 2022, 06:52:08 AM

Previous topic - Next topic

LauReis

 :(
Good morning everyone
I'm new here, and I have a problem, when using a DCL and clicking [Done...], this button Loads the '#Quadrados_Filas' function, when it finds a command in the code lines (vl-cmdf "xxx") the routine automatically returns to the dialog box (DCL ).
The fact is that she is interrupted, returning to the DCL
I don't understand why this happens, I would like some help.
I made a video showing when the command "QF" is used it works perfectly, but when used in DCL "OQF", it goes back to the DCL. ???
I'm waiting for help, thank you

QF = Keyboard command
OQF = OpenDCL Command
.Both run the same function (#Quadrados_filas), but when used the OQF is interrupted.

owenwengerd

While you are showing a modal dialog it is not possible to send commands because the command throat is suspended waiting for the dialog to close. Functions like (command) and (cl-cmdf) will fail from inside a modal dialog event handler. If you cannot avoid executing commands, you will need to make your form modeless. I hope that helps.
Owen Wengerd (Outside The Box) / ManuSoft

LauReis

Thank you owenwengerd

But I still don't understand how to solve my case.
but on line 35 and loaded the closing function of the DCL, this should inhibit the error ?
check the .lsp inside the .zip file
Sorry I can't put a part of the COD here, even copying and pasting at the end it erases everything and appears: ; BOT

owenwengerd

A form cannot close while a handler is executing, so your (dcl_form_close CUR_form1) does *not* close the form. Not until (dcl_form_show) returns is your form closed. Try putting the (#Quadrados_Filas) immediately after (dcl_form_show), then the form will be closed and it will be possible to run commands again.
Owen Wengerd (Outside The Box) / ManuSoft

LauReis

Thanks it worked perfectly.
But I was confused.
it's like a break, only the later lines are played.... after [done...]



; CARREGA A CAIXA DE DIGALOGO BOX   PELO OPEN.DCL.
(defun c:OQF()
  (IF (= #SISTM-CF NIL) (PROGN (#CF_#Confg_System_Metrico)    (SETQ #SISTM-CF T) ))
  (command "_OPENDCL")                      ; CARREGA O DCL .ARX
  (dcl_project_load "Y:\\OPEN.DCL\\CUR" t)  ; CARREGA O ARQUIVO CUR.DCL
  (dcl_form_show CUR_form1)(PRINC)          ; ATIVA O DCL
  (#Quadrados_Filas)                        ; (this Line is only executed after clicking [done] )
)