我收到此错误类型:
error: bad argument type: (or stringp symbolp): 1`
有人知道为什么吗?我认为这是在最后if
。
(defun C:girth ( / dcl_id gr_ded)
(setq NAMES '("0.032 in" "0.050 in" "0.080 in" "1/8 in" "1/4 in" "16 GA" "18 GA" "20 GA"))
(setq dcl_id (load_dialog "girth.dcl"))
(if (not (new_dialog "girth" dcl_id))
(exit)
)
(start_list "selections")
(mapcar 'add_list NAMES)
(end_list)
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
);action_tile
(action_tile
"accept"
(strcat
"(progn
(if (or (= \"selections\" \"0.032 in\") (= \"selections\" \"20 GA\"))
(setq gr_ded 0)
(if (or (= \"selections\" \"0.050 in\") (= \"selections\" \"18 GA\"))
(setq gr_ded 0.0625)
(if (or (= \"selections\" \"0.080 in\") (= \"selections\" \"16 GA\"))
(setq gr_ded 0.125)
(if (= \"selections\" \"1/8 in\")
(setq gr_ded 0.1875)
(if (= \"selections\" \"3/16 in\")
(setq gr_ded 0.3125)
(if (= \"selections\" \"1/4 in\")
(setq gr_ded 0.375)
(setq gr_ded 1)
)
)
)
)
)
)
(alert \"Value: \" (getvar gr_ded)))"
);strcat
);action tile
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
这是“新”代码(仍无效):
gr_ded
现在为m_deduct
,selections
为thk
。
(defun C:girth ( / dcl_id m_deduct mat_thk)
(setq NAMES '("0.032 in" "0.050 in" "0.080 in" "1/8 in" "1/4 in" "16 GA" "18 GA" "20 GA"))
(setq dcl_id (load_dialog "girth.dcl"))
(if (not (new_dialog "girth" dcl_id))
(exit)
)
(start_list "thk")
(mapcar 'add_list NAMES)
(end_list)
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
);action_tile
(action_tile
"accept"
(strcat "(progn (setq mat_thk (get_tile \"thk\"))"
"(done_dialog) (setq UserClick T))"
);strcat
);action_tile
(start_dialog)
(unload_dialog dcl_id)
(if (= UserClick T)
(progn
(cond ((or (= mat_thk "0.032 in") (= mat_thk "20 GA"))
(setq m_deduct 0)
)
((or (= mat_thk "0.050 in") (= mat_thk "18 GA"))
(setq m_deduct 0.0625)
)
((or (= mat_thk "0.080 in") (= mat_thk "16 GA"))
(setq m_deduct 0.125)
)
((= mat_thk "1/8 in")
(setq m_deduct 0.1875)
)
((= mat_thk "3/16 in")
(setq m_deduct 0.3125)
)
((= mat_thk "1/4 in")
(setq m_deduct 0.375)
)
(t (setq m_deduct 1))
);_cond
(alert (strcat "Value: " (rtos m_deduct 2 5)))
);progn
);if userclick
(princ)
);defun
Girth.dcl
girth : dialog {
label = "MyTitle";
initial_focus = "ang1";
: boxed_radio_column {
label = "Calc";
: row {
: popup_list {
label = "Thick:";
key = "thk";
value = "1";
}
: text_part {
label = "Option 1";
}
}
spacer;
: row {
: edit_box {
label = "Angle 1:";
edit_limit = 6;
edit_width = 6;
key = "ang1";
}
: edit_box {
label = "Dim 1:";
edit_limit = 7;
edit_width = 7;
key = "dim1";
}
}
: row {
: edit_box {
label = "Angle 2:";
edit_limit = 6;
edit_width = 6;
key = "ang2";
}
: edit_box {
label = "Dim 2:";
edit_limit = 7;
edit_width = 7;
key = "dim2";
}
}
: row {
: edit_box {
label = "Angle 3:";
edit_limit = 6;
edit_width = 6;
key = "ang3";
}
: edit_box {
label = "Dim 3:";
edit_limit = 7;
edit_width = 7;
key = "dim3";
}
}
: row {
: edit_box {
label = "Angle 4:";
edit_limit = 6;
edit_width = 6;
key = "ang4";
}
: edit_box {
label = "Dim 4:";
edit_limit = 7;
edit_width = 7;
key = "dim4";
}
}
: row {
: edit_box {
label = "Angle 5:";
edit_limit = 6;
edit_width = 6;
key = "ang5";
}
: edit_box {
label = "Dim 5:";
edit_limit = 7;
edit_width = 7;
key = "dim5";
}
}
: row {
: edit_box {
label = "Angle 6:";
edit_limit = 6;
edit_width = 6;
key = "ang6";
}
: edit_box {
label = "Dim 6:";
edit_limit = 7;
edit_width = 7;
key = "dim6";
}
}
: row {
: edit_box {
label = "Angle 7:";
edit_limit = 6;
edit_width = 6;
key = "ang7";
}
: edit_box {
label = "Dim 7:";
edit_limit = 7;
edit_width = 7;
key = "dim7";
}
}
: row {
spacer;
}
}
: row {
key = "det";
: radio_button { label = "A"; value = "1"; }
: radio_button { label = "B"; }
: radio_button { label = "C"; }
}
ok_cancel;
}
答案 0 :(得分:0)
我认为它就行了:
(alert \"Value: \" (getvar gr_ded)))
尝试替换为:
(alert (strcat \"Value: \" (rtos gr_ded)))
不确定gr_ded
。它似乎是一个数字但你为什么用它来调用getvar
?
你应该使用cond
而不是嵌套if。
strcat
的第二个参数中的action_tile
是多余的。