Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Error message when Dialog Box opens - error to few arguments

  1. #1
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Error message when Dialog Box opens - error to few arguments

    Here is the lisp code and dcl. When i run this the dialogue box opens up but as soon as it opens up it goes away and the command line says error to few arguments. I am not real familiar with dialogue boxes in code so all help will be appreciated.

    Lisp code
    Code:
    (defun C:filter ()
      (setq ff (list "" "2in." "4in."))
      (setq dcl_id (load_dialog "filter.DCL"))
      (if
        (not (new_dialog "filter" dcl_id))
        (exit)
        )
      (set_tile "fr" "0")
      (set_tile "fc" "0")
      (set_tile "ff")
    
      (mode_tile "fr" 2)
      (mode_tile "fc" 2)
      (mode_tile "ff" 2)
    
      (action_tile "fr" "(setq data_fr (get_tile \"fr\"))")
      (action_tile "fc" "(setq data_fc (get_tile \"fc\"))")
      (action_tile "ff" "(setq data_ff (get_tile \"ff\"))")
    
      (action_tile "accept" "(done_dialog 1)")
      (action_tile "cancel" "(done_dialog 0)")
      (setq ans (start_dialog))
      (unload_dialog dcl_id)
      
      (setq old_osnap1 (getvar "osmode"))
      (setvar "osmode" 0)
      (setq filr (atoi data_fr))
      (setq filc (atoi data_fc))
      (setq filf (atoi data_ff))
       (fillayout)
      (setvar "osmode" old_osnap1)
    )
    
    (defun fillayout ()
      (setq filpnt (getpoint "\n Select Placement of filter"))
      (setq filpnt1(polar filpnt (dtr 0) filf))
      (setq filpnt2(polar filpnt1(dtr 90)(* filr 24)))
      (setq filpnt3(polar filpnt2(dtr 180)filf))
       (command "line" filpnt filpnt1 filpnt2 filpnt3"C")
      (while (<(cadr filpnt) (-(cadr filpnt3)24))
          (setq filpnt(list (car filpnt)(+(cadr filpnt)24)))
          (setq filpnt1 (list (car filpnt1) (+(cadr filpnt1)24)))
          (command "line" filpnt filpnt1"")
      );; end of while
      (fillclayout)
    );; end of fillayout
    
    
    (defun fillclayout ()
      (setq filpnt4 (polar filpnt3 (dtr 90) 24))
      (setq filpnt5(polar filpnt4 (dtr 0) filf))
      (setq filpnt6(polar filpnt5(dtr 90)(* filc 24)))
      (setq filpnt7(polar filpnt6(dtr 180)filf))
       (command "line" filpnt4 filpnt5 filpnt6 filpnt7"C")
      (while (<(cadr filpnt4) (-(cadr filpnt7)24))
          (setq filpnt4(list (car filpnt4)(+(cadr filpnt4)24)))
          (setq filpnt5 (list (car filpnt5) (+(cadr filpnt5)24)))
          (command "line" filpnt4 filpnt5"")
      );; end of while
    );; end of fillayout
    DCL
    Code:
    filter : dialog {label = "Flat Filters";
       : column {label = "Information";
       : edit_box {label = "Enter Number of Filter Rows:";
                   key = "fr";
                   edit_limit = 8;
                   edit_width = 8;}
       : edit_box {label = "Enter Number of Filter Columns:";
                   key = "fc";
                   edit_limit = 8;
                   edit_width = 8;}
       : popup_list {label = "Enter Width of Unit:";
                   key = "ff";
                   edit_limit = 8;
                   edit_width = 8;}}
    
      spacer;
        ok_cancel;   
      spacer;
      spacer;
      spacer;
      :text_part{label = "Designed and Created";}
      :text_part{label = "by Jeremy Preston";}}

  2. #2
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Start by changing
    (set_tile "ff")
    to
    (set_tile "ff" "0")
    or whatever value its supposed to be...

  3. #3
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Ok that solved the problem with the dialogue not staying on the screen. Now i am having a problem with my popup_list. There are no values in it.

  4. #4
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    You might also get some use out of this...

    Regards
    Phill

    Also you are setting the var "ans" using (setq ans (start_dialog)) but then your not checking what the answer is..
    (if (= ans 1)
    (progn
    (setq old_osnap1 (getvar "osmode"))
    (setvar "osmode" 0)
    (setq filr (atoi data_fr))
    (setq filc (atoi data_fc))
    (setq filf (atoi data_ff))
    (fillayout)
    (setvar "osmode" old_osnap1)
    )
    )
    Attached Files Attached Files

  5. #5
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Quote Originally Posted by Lions60
    Ok that solved the problem with the dialogue not staying on the screen. Now i am having a problem with my popup_list. There are no values in it.
    to fill a list tile you use the "start_list" and "end_list" functions

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

    and then to preselect an item in the list use set_tile
    (set_tile "ff" "1")
    remember that the first item in a list is "0" not "1"



  6. #6
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Thank you for your help. This is one of my first attempts with lisp and dcl's.

  7. #7
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Quote Originally Posted by Lions60
    Thank you for your help. This is one of my first attempts with lisp and dcl's.
    You're welcome.

    another question
    What is your reason for defining your list for the popup list with "" as the first element?
    (setq ff (list "" "2in." "4in."))

  8. #8
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    I have no idea. That has been taken out. I am still having one problem though. If in the popup list i select 2 then (setq filf(atoi data_ff)) should be set to 2, but its not set to 2. how do i get the value that was selected in the list.

  9. #9
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Quote Originally Posted by Lions60
    I have no idea. That has been taken out. I am still having one problem though. If in the popup list i select 2 then (setq filf(atoi data_ff)) should be set to 2, but its not set to 2. how do i get the value that was selected in the list.
    The value returned by a dcl list is a string, containing an integer or integers for the position of the selected item or items in the list starting with "0" for the first item. You then need to convert this position number into the actual value from your list. There are several method for doing this. I have chosen one and done it for you below.

    I have also taken the liberty of making a fewother changes. I have added error handling, and default memory for the dcl including some global vars, declared your other variables local and a few other minor tweaks. Let me know if you cant make sense of the changes.

    Also you should avoid redefining standard autocad commands like "filter". I have changed the command to c:FTR

    Code:
    (defun c:FTR ( / ff ff# dcl_id ans data_fr data_fc data_ff filr filc filf old_osnap1 cmdecho *error*)
      (defun *error* (MSG) ; local error handler to reset entity redraw
    	(princ (strcat "\n" MSG))  ; return the error message
    	(if old_osnap1 (setvar "osmode" old_osnap1))
    	(if cmdecho (setvar "cmdecho" cmdecho))
      )
      (setq ff '("2\"" "4\"")
    		ff# '(2 4)
      )
      (setq dcl_id (load_dialog "filter.DCL"))
      (if (not (new_dialog "filter" dcl_id))(exit))
      (if (not *data_fr*)(setq *data_fr* 2))
      (if (not *data_fc*)(setq *data_fc* 2))
      (if (not *data_ff*)(setq *data_ff* "0"))
      (setq data_fr *data_fr*
    		data_fc *data_fc*
    		data_ff *data_ff*
      )
      (set_tile "fr" (itoa data_fr))
      (set_tile "fc" (itoa data_fc))
      (start_list "ff")
      (mapcar 'add_list ff)
      (end_list)
      (set_tile "ff" data_ff)
      (mode_tile "ff" 2)
      (action_tile "accept" "(get:dcl_filter)(done_dialog 1)")
      (action_tile "cancel" "(done_dialog 0)")
      (setq ans (start_dialog))
      (unload_dialog dcl_id)
      (if (= ans 1)
    	(progn
    	  (setq old_osnap1 (getvar "osmode")
    			cmdecho (getvar "cmdecho")
    	  )
    	  (setvar "osmode" 0)
    	  (setq filr *data_fr*
    			filc *data_fc*
    			filf (nth (atoi *data_ff*) ff#)
    	  )
    	  (fillayout)
    	  (setvar "osmode" old_osnap1)
    	  (setvar "cmdecho" cmdecho)
    	)
      )
    (princ)
    )
    (defun get:dcl_filter ()
      (setq data_fr (atoi (get_tile "fr"))
    		data_fc (atoi (get_tile "fc"))
    		data_ff (get_tile "ff")
    		*data_fr* data_fr
    		*data_fc* data_fc
    		*data_ff* data_ff
      )
    )
    (defun fillayout ( / filpnt filpnt1 filpnt2 filpnt3)
      (setq filpnt (getpoint "\nSelect Placement of filter"))
      (setvar "cmdecho" 0)
      (setq filpnt1 (polar filpnt (dtr 0) filf)
    		filpnt2 (polar filpnt1 (dtr 90) (* filr 24))
    		filpnt3 (polar filpnt2 (dtr 180) filf)
      )
      (command "line" filpnt filpnt1 filpnt2 filpnt3 "C")
      (while (< (cadr filpnt) (- (cadr filpnt3) 24))
    	  (setq filpnt (list (car filpnt)(+ (cadr filpnt) 24)))
    	  (setq filpnt1 (list (car filpnt1) (+ (cadr filpnt1) 24)))
    	  (command "line" filpnt filpnt1 "")
      );; end of while
      (fillclayout)
    );; end of fillayout
    
    (defun fillclayout ( / filpnt4 filpnt5 filpnt6 filpnt7)
      (setq filpnt4 (polar filpnt3 (dtr 90) 24)
    		filpnt5 (polar filpnt4 (dtr 0) filf)
    		filpnt6 (polar filpnt5 (dtr 90) (* filc 24))
    		filpnt7 (polar filpnt6 (dtr 180) filf)
      )
      (command "line" filpnt4 filpnt5 filpnt6 filpnt7 "C")
      (while (< (cadr filpnt4) (- (cadr filpnt7) 24))
    	  (setq filpnt4 (list (car filpnt4) (+ (cadr filpnt4) 24)))
    	  (setq filpnt5 (list (car filpnt5) (+ (cadr filpnt5) 24)))
    	  (command "line" filpnt4 filpnt5 "")
      );; end of while
    );; end of fillayout
    Code:
    filter : dialog {label = "Flat Filters";
       : boxed_column {label = "Information";
    	 : edit_box {label = "Enter Number of Filter Rows:";key = "fr";edit_limit = 8; edit_width = 9;}
    	 : edit_box {label = "Enter Number of Filter Columns:";key = "fc";edit_limit = 8;edit_width = 9;}
    	 : popup_list {label = "Enter Width of Unit:";key = "ff";edit_limit = 8;edit_width = 8;}
    	 : spacer {height=0.5;}
       }
       spacer_1;
       ok_cancel;   
       spacer_1;
       :text_part {label = " Designed and Created";}
       :text_part {label = " by Jeremy Preston";}
    }
    Regards
    Phill
    Attached Files Attached Files

  10. #10
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Error message when Dialog Box opens - error to few arguments

    Thanks i now understand how to return the value from the popup. I appreciate your help.

Page 1 of 2 12 LastLast

Similar Threads

  1. Error: too few arguments in a function
    By twitchyChuck in forum AutoLISP
    Replies: 6
    Last Post: 2013-06-07, 09:24 PM
  2. error: too many arguments??
    By tedg in forum AutoLISP
    Replies: 3
    Last Post: 2010-08-31, 02:58 AM
  3. Replies: 8
    Last Post: 2009-10-27, 12:03 PM
  4. error: too many arguments Using IF Function
    By ccruz in forum AutoLISP
    Replies: 1
    Last Post: 2009-08-06, 09:31 PM
  5. Help fix a routine - Error: too few arguments
    By cadd4la in forum AutoLISP
    Replies: 3
    Last Post: 2006-01-10, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •