乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 90|回复: 4

[编程交流] ; error: bad argument type: li

[复制链接]

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 00:50:02 | 显示全部楼层 |阅读模式
hi
 
have my first dcl
 
  1. (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 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 )
 
  1. 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
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 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.
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 01:21:46 | 显示全部楼层
Some other issues:
 
There is a line that should be commented:
  1. (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:
  1. (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:
  1. (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):
  1. (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.
回复

使用道具 举报

0

主题

301

帖子

301

银币

初来乍到

Rank: 1

铜币
0
发表于 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.
 
 
  1. ;; extract the values (setq fname (cdr (assoc 42 (getdiaval)))       lname (cdr (assoc 43 (getdiaval)))       age   (cdr (assoc 3  (getdiaval))) )
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 01:53:34 | 显示全部楼层
Thanks you all guys
 
the final working code drived from your comments
 
  1. (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 "."  )) )
 
  1. 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;}}}
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 21:10 , Processed in 0.393349 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表