samifox 发表于 2022-7-6 00:50:02

; error: bad argument type: li

hi
 
have my first dcl
 

(defun C:Test(/ fname lname age dialogLoaded dialogShow      dcl_id ) ;; extract the values (setq fname    (cdr (assoc 42 getDiaVal))lname(cdr (assoc 43 getDiaVal))age      (cdr (assoc 3getDiaVal)) ) (alert (strcat"your first name is " fname"your last name is " lname"your age is " age)) )(defun getDiaVal(/ fname lname age dialogLoaded dialogShow      dcl_id) ;define defult value for text box (setq fname "first name"lname "last name"age "0"       dialogLoaded TdialogShow T) ;; Load the DCL file.   (if (= -1 (setq dcl_id (load_dialog "simple.dcl")))   (progn   ;; There's a problem - display a message and set the   ;; dialogLoaded flag to nil   (princ "\nERROR: Cannot load gpdialog.dcl")   (setq dialogLoaded nil)   ) ;_ end of progn ) ;_ end of if ;; Load the dialog box   (if (and dialogLoaded   (not (new_dialog "simple_dcl" dcl_id))   ) ;_ end of and   (progn   ;; There's a problem...   (princ "\nERROR: Cannot show dialog gp_mainDialog")   (setq dialogShow nil)   ) ;_ end of progn ) ;_ end of if ;initilizing defualt values (if (and dialogLoaded dialogShow)   (progn   ;; Set the initial state of the tiles   (set_tile "fname" fname)   (set_tile "lname" lname)   (set_tile "age" age)   ) )   ;; invoke the dialog.          (start_dialog)   ;; OK or cancel has been hit, you're out of the dialog.Unload it   (unload_dialog dcl_id)   ;; Build the resulting data       (if UserClick(progn(setq Result (list   (cons 42 fname)   (cons 43 lname)   (cons 3 age)   ) ;_ end of list) ;_ end of setq) ;_ end of progn   ) ;_ end of if ;assign action to tiles (action_tile"accept"(strcat "(progn (setq fname (get_tile \"fname\")))" "(setq lname (get_tile \"lname\")))" "(setq age (get_tile \"age\")))" "(done_dialog) (setq UserClick T))") ;_ end of strcat) ;_ end of action tile Result )
 

simple_dcl : dialog {label = "My First DCL"; // the labal on the blue bar initial_focus = "fname"; // what box get the fucus first spacer;: row {   fixed_width = true;      : column {   width = 30;   //fixed_width = true;   spacer;          : text {         label = "First Name";   }   }      : edit_box {   key = "fname";   edit_width = 20;   //fixed_width = true;   } } : row {   fixed_width = true;      : column {   width = 30;   //fixed_width = true;   spacer;          : text {         label = "Last Name";   }   }      : edit_box {   key = "lname";   edit_width = 20;   //fixed_width = true;   } } : row {   fixed_width = true;      : column {   width = 30;   //fixed_width = true;   spacer;          : text {         label = "Age";   }   }      : edit_box {   key = "age";   edit_width = 20;   //fixed_width = true;   } } : row {          // defines the OK/Cancel button row : spacer { width = 1; } : button {    // defines the OK button   label = "OK";   is_default = true;   key = "accept";   width = 8;   //fixed_width = true; } : button {    // defines the Cancel button   label = "Cancel";   is_cancel = true;   key = "cancel";   width = 8;   //fixed_width = true; } : spacer { width = 1;}}}
 
get this error
 
; error: bad argument type: listp #
 
cant figure out
 
Thanks
S

MSasu 发表于 2022-7-6 01:18:50

At a glance, the definition for getDiaVal is placed after is called; there may be some other issues, I didn't went deeper in your code.

MSasu 发表于 2022-7-6 01:21:46

Some other issues:
 
There is a line that should be commented:

(setq Result (list   (cons 42 fname)   (cons 43 lname)   (cons 3 age)   ) ;_ ;end of list) ;_ end of setq
 
Similar comment issue + Verify that there are some extra closing paranthesis on the action_tile:

(action_tile"accept"(strcat "(progn (setq fname (get_tile \"fname\")))"               "(setq lname (get_tile \"lname\")))"               "(setq age (get_tile \"age\")))"               "(done_dialog) (setq UserClick T))") ;_ end;of strcat) ;_ end of action tile
 
The getDiaVal is a function, cannot be called like a variable:

(setq fname    (cdr (assoc 42 (getDiaVal)))
Also please pay attention that you are calling the dialog three times in a row!
 
You attempted to build a associative list with the result of dialog, but I'm afraid that that code isn't reachable after you call done_dialog. I would let the dialog read function variables to visible at main's function level instead (where are declared local anyway):

(defun getDiaVal( / ;fname lname age dialogLoaded dialogShow dcl_id                )
 
 
There are also some issues with the formatting of your DCL definition - check that you have some broken comments and labels; also there is an un-supported "button row" keyword and a floating "button" one.

ymg3 发表于 2022-7-6 01:45:45

Samifox,
 
Cause of the errors is you are calling a subroutine, you need to put it in between parenthesis (getdiaval).
 
Please format your code a little when you post.Very difficult to help you.
 
Sorry, about that MSasu did not see your reply.We were posting at the same time.
 
 

;; extract the values (setq fname (cdr (assoc 42 (getdiaval)))       lname (cdr (assoc 43 (getdiaval)))       age   (cdr (assoc 3(getdiaval))) )

samifox 发表于 2022-7-6 01:53:34

Thanks you all guys
 
the final working code drived from your comments
 

(defun getDiaVal(/ fname lname age dialogLoaded dialogShow      dcl_id) ;define defult value for text box (setq fname "first name"         lname "last name"          age "0"          dialogLoaded T          dialogShow T) ;; Load the DCL file.   (if (= -1 (setq dcl_id (load_dialog "simple.dcl")))   (progn   ;; There's a problem - display a message and set the   ;; dialogLoaded flag to nil   (princ "\nERROR: Cannot load simple_dcl.dcl")   (setq dialogLoaded nil)   ) ;_ end of progn ) ;_ end of if ;; Load the dialog box   (if (and dialogLoaded   (not (new_dialog "simple_dcl" dcl_id))   ) ;_ end of and   (progn   ;; There's a problem...   (princ "\nERROR: Cannot show dialog gp_mainDialog")   (setq dialogShow nil)   ) ;_ end of progn ) ;_ end of if ;initilizing defualt values (if (and dialogLoaded dialogShow)   (progn   ;; Set the initial state of the tiles   (set_tile "fname" fname)   (set_tile "lname" lname)   (set_tile "age" age)   ) ) ;assign action to tiles (action_tile "cancel" "(done_dialog) (setq UserClick nil)") (action_tile"accept"(strcat "(progn (setq fname (get_tile \"fname\"))" "(setq lname (get_tile \"lname\"))" "(setq age (get_tile \"age\"))" "(done_dialog) (setq UserClick T))") ;_ end of strcat) ;_ end of action tile   ;; invoke the dialog.   (start_dialog)   ;; OK or cancel has been hit, you're out of the dialog.Unload it   (unload_dialog dcl_id)   ;; Build the resulting data(if UserClick(progn(setq Result (list   (cons 42 fname)   (cons 43 lname)   (cons 3 age)   ) ;_ end of list) ;_ end of setq) ;_ end of progn   ) ;_ end of if Result ) (defun C:Test(/ fname lname age dialogLoaded dialogShow      dcl_id ) ;; extract the values (setq diare (getDiaVal)) (setq fname    (cdr (assoc 42 diare))          lname(cdr (assoc 43 diare))         age      (cdr (assoc 3 diare)) )(alert (strcat"your first name is " fname ",""your last name is " lname ",""your age is " age ".")) )
 

simple_dcl : dialog { label = "My First DCL"; initial_focus = "fname";spacer; : row {   fixed_width = true;   : column {   width = 30;   fixed_width = true;   spacer;   : text {         label = "First Name";         }      }   : edit_box         {   key =   "fname";   edit_width = 20;   fixed_width = true;} } : row {   fixed_width = true;   : column {   width = 30;   fixed_width = true;   spacer;   : text {         label = "Last Name";   }}   : edit_box {   key = "lname";   edit_width = 20;   fixed_width = true;} } : row {   fixed_width = true;   : column {   width = 30;   fixed_width = true;   spacer;   : text {         label = "Age";   }}   : edit_box {   key = "age";   edit_width = 20;   fixed_width = true;} }: row {          : spacer { width = 1; } : button {       label = "OK";   is_default = true;   key = "accept";   width = 8;   fixed_width = true; } : button {      label = "Cancel";   is_cancel = true;   key = "cancel";   width = 8;   fixed_width = true; } : spacer { width = 1;}}}
页: [1]
查看完整版本: ; error: bad argument type: li