Author Topic: Unexpected loop when executing function (returns to DCL)  (Read 237 times)

LauReis

  • Member
  • *
  • Posts: 3
Unexpected loop when executing function (returns to DCL)
« on: May 21, 2022, 06:52:08 AM »
 :(
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.
« Last Edit: May 24, 2022, 04:05:38 AM by LauReis »

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 3073
    • Outside The Box
Re: Unexpected loop when executing function (returns to DCL)
« Reply #1 on: May 30, 2022, 05:21:37 PM »
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.

LauReis

  • Member
  • *
  • Posts: 3
Re: Unexpected loop when executing function (returns to DCL)
« Reply #2 on: May 31, 2022, 08:32:27 AM »
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
« Last Edit: May 31, 2022, 08:35:24 AM by LauReis »

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 3073
    • Outside The Box
Re: Unexpected loop when executing function (returns to DCL)
« Reply #3 on: June 02, 2022, 01:40:09 PM »
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.

LauReis

  • Member
  • *
  • Posts: 3
Re: Unexpected loop when executing function (returns to DCL)
« Reply #4 on: June 03, 2022, 06:41:57 AM »
Thanks it worked perfectly.
But I was confused.
it's like a break, only the later lines are played.... after [done...]

Code: [Select]

; 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] )
)
« Last Edit: June 03, 2022, 06:43:52 AM by LauReis »