[Solved] "dcl-Form-Show" returns "too many arguments"

Started by Peter2, August 09, 2016, 08:51:59 AM

Previous topic - Next topic

Peter2

EDIT: Solved - see below.
------------------

I have a modal dialogue to insert blocks, displayed in "images". There is a loop to

- open the dialogue initially
- close and open it when double-clicking the images
- close it when the button "close" (or Esc ..) are pressed.

As reported in the "Subject" of this posting. "dcl-Form-Show" returns "too many arguments" ...??

This is my structure:

Code (autolisp) Select

; start of main-function
(defun c:MyApp (/ cmdecho form-type first-run value)

--> do some readings and preparartions and settings ...

    ;; Load the project
    (dcl-Project-Load "MyApp.odcl")

    ;; Show the main form
    (setq dialogstatus 20) ; the doubleclick on the images set this value on 20 to keep the loop alive until "Close"

    (while (= dialogstatus 20)

        (setq dialogstatus (dcl-Form-Show MyApp/MyApp))      ; here the modal dialogue will be shown. dialogstatus will be set via the close-commands

; a) here "oninitialize" will work
; b) then the doubleclick-events will work

        (if (= dialogstatus 20) ; if I click an image, 20 will be used and the loop continues
            (progn
                --> do something
            )
        )
    ) ; ende while
    (princ)
)
; end of main-function


; oninitialize
(defun c:MyApp/MyApp#OnInitialize (/)
--> do some communication between existing values and the display of controls, start the display of the images (load picture)
    (princ "\nInitialize fertig.")
)

; one doubleclick-event on "image"
(defun c:MyApp/MyApp/SigTaf_WMF1#OnDblClicked ()
--> do something, then close the dialogue with the value 20 to keep the loop alive
    (dcl-Form-Close MyApp/MyApp 20)
)

--> The CLOSE here returns 20 to the previous SHOW from above; then it does something and the loop keeps on.

; the standard close button
(defun c:MyApp/MyApp/Exit#OnClicked (/)
(dcl-Form-Close MyApp/MyApp 10)
)
--> this returns 10 to the SHOW from above, the loop will end.

The message "too many arguments" appears both when the dialogue starts the first time or when it is re-started from the loop.

What's wrong? The basic structure of the routine?

Thanks and regards
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

cadplayer

Hello Peter!
I not realy understand why should use variable dialogstatus.
Do you have problems to start form-dialog ?
If I run your code it works for me, but do you have some misstakes in named of dialog ?

here is my example with recall values after ->..., may it helps
(progn
  (command "_OPENDCL")
  (setq form (dcl-project-load "Form1.odcl")) ; -> "Form1"
  (setq returnResult (dcl-Form-Show Form1/Dialog_Option)) ; -> 1
  )

Peter2

Quote from: cadplayer on August 09, 2016, 10:21:13 AM
...I not realy understand why should use variable dialogstatus....
Because there are different situations when closing the dialogue, and a different status can start different reactions.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

roy_043

Why do you think the problem is with dcl_Form-Show and not with c:MyApp/MyApp#OnInitialize?

Peter2

Quote from: roy_043 on August 09, 2016, 01:27:08 PM
Why do you think the problem is with dcl_Form-Show and not with c:MyApp/MyApp#OnInitialize?
I wrote messages with "princ" to the code, and the appearance of the "too many arguments - message" showed me where it comes from.

But just now I also deactivated the "oninitialize-event" and the "oninitialize-code", and the message still appears.

To be clear: The message appears in the command-line, not in a dialogue.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

roy_043

Your problem is not caused by the dcl_Form-Show function. If that were the case the dialog would not display. IMO one of the ODCL event handlers must therefore be to blame. Try disabling all events and then switching them back on one by one.

Peter2

Quote from: roy_043 on August 10, 2016, 01:49:03 AM
Your problem is not caused by the dcl_Form-Show function. If that were the case the dialog would not display. IMO one of the ODCL event handlers must therefore be to blame. ...
Yes - you are right.

Thanks to the detailed error reports in Bricscad I found the problem. BricsCAD told me:

Code (autolisp) Select
Initialize fertig.
; ----- LISP : Call Stack -----
; [0]...C:MyApp
; [1].....DCL-FORM-SHOW <<--
;
; ----- Error around expression -----
(AL_EXECUTEADSDEFUN "DCL-FORM-CLOSE" REST)
;
; error : too few / too many arguments at [eval]
;
; error : during LISP function [c:MyApp/MyApp#OnClose] invoke from BRX/SDS interface,
          please check Lisp function definition and call arguments.


The reason behind was that I used the wrong code in "OnClose"
Code (autolisp) Select
(defun c:MyApp/MyApp#OnClose ( /)
the right code is
Code (autolisp) Select
(defun c:MyApp/MyApp#OnClose (intUpperLeftX intUpperLeftY /)
Thanks for help.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10