Jump to content

; error: bad argument type: listp #<USUBR @000000002de014d0 GETDIAVAL>


Recommended Posts

Posted

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 3  
getDiaVal))
 )
 
(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 
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 
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

Posted

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.

Posted

Some other issues:

 

There is a line that should be commented:

(setq Result 
(list
   (cons 42 fname)
   (cons 43 
lname)
   (cons 3 age)
     ) ;_ 
[color=red];end of list[/color]
  ) ;_ 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\"))[color=red][s])[/s][/color][color=#000000]"[/color]
               "(setq lname (get_tile \"lname\"))[color=#ff0000][s])[/s][/color][color=#000000]"[/color]
               "(setq age (get_tile \"age\"))[color=#ff0000][s])[/s][/color][color=#000000]"[/color]
               "(done_dialog) (setq UserClick T))"
) ;_ end
[color=red];of strcat[/color]
  ) ;_ end of action tile

 

The getDiaVal is a function, cannot be called like a variable:

(setq fname    
(cdr (assoc 42 [color=red]([/color]getDiaVal[color=red])[/color]))

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( / [color=red];fname lname age dialogLoaded dialogShow dcl_id[/color]
                )

 

 

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.

Posted

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)))
 )

Posted

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;}
}
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...