第二个弹出窗口的值
你好当一个对话框中有两个弹出列表时,我们想得到第二个弹出列表的值,
下面的get\u tile函数将第一个列表视为0,第二个列表的值
如何获取第二个弹出列表的值,因为第一个列表未激活,尽管其值为0 实例
DCL代码。。
txt: dialog {
label = "texts";
: column {
: row {
:boxed_column {
:radio_button { key = "rad1";label = "50-500" ; }
:radio_button { key = "rad2";label = "500-1000" ; }
}
:boxed_column {
:row {: popup_list { key = "h1"; is_enabled = true; }}
:row {: popup_list { key = "h2"; is_enabled = false;}}
}}
: boxed_row {
: button { key = "accept"; label = " Okay "; is_default = true; }
: button { key = "cancel"; label = " Cancel "; is_default = false; is_cancel = true;}
}
}
}
Lisp代码。。。
(defun c:Test (/ dcl_id lst1 lst2 val1 val2 size1 size2)
(setq dcl_id (load_dialog "txt.dcl"))
(if (not (new_dialog "txt" dcl_id))
(exit)
)
(start_list "h1")
(mapcar 'add_list
(setq lst1 '("50" "75" "100" "125" "150" "200" "250" "300"
"350" "400" "450" "500"
)
)
)
(end_list)
(start_list "h2")
(mapcar 'add_list
(setq lst2 '("550" "600" "650" "700" "750" "800" "850" "900"
"950" "1000"
)
)
)
(end_list)
(set_tile "rad1" "1")
(action_tile
"rad1"
"(setq val1 $value)(mode_tile \"h1\" (boole 1 1 0))(mode_tile \"h2\" (boole 1 1 (atoi val1)))"
)
(action_tile
"rad2"
"(setq val2 $value)(mode_tile \"h2\" (boole 1 1 0))(mode_tile \"h1\" (boole 1 1 (atoi val2)))"
)
(action_tile
"accept"
"(setq size1 (atoi (get_tile \"h1\")))(setq size2 (atoi (get_tile \"h2\")))(setq done t)(done_dialog)"
)
(action_tile "cancel" "(setq done nil)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(if done
(progn
(princ (eval size1)) ;;<= would always have a value , even if it was not chosen ( activated )
(princ (eval size2))
)
)
(princ)
)
此外,尽量不要使动作的表达过于拥挤;使用专用功能。 谢谢米尔恰。
我以前试过,但它总是返回一个nil值,我的意思是get\u tile函数。
(defun OnOK()
(if (= (get_tile "rad1") "1")
(setq size1 (atoi (get_tile "h1")))
(setq size2 (atoi (get_tile "h2")))
)
(setq done t)
(done_dialog)
)
(action_tile "accept""(OnOK)") 请澄清一下,你在哪里进行的测试? 测试代码,并注意到命令行的返回值将为零。
(get_tile "rad1"); nil
(get_tile "h1") ; nil
(get_tile "h2"); nil
这应该满足您的期望:
(defun c:Test (/ dcl_id lst1 lst2 val1 val2 size1 size2)
(setq dcl_id (load_dialog "txt.dcl"))
(if (not (new_dialog "txt" dcl_id))
(exit)
)
(start_list "h1")
(mapcar 'add_list(setq lst1 '("50" "75" "100" "125" "150" "200" "250" "300" "350" "400" "450" "500" )))
(end_list)
(start_list "h2")
(mapcar 'add_list (setq lst2 '("550" "600" "650" "700" "750" "800" "850" "900""950" "1000" )))
(end_list)
(set_tile "rad1" "1")
(action_tile"rad1" "(setq val1 $value)(mode_tile \"h1\" (boole 1 1 0))(mode_tile \"h2\" (boole 1 1 (atoi val1)))" )
(action_tile"rad2""(setq val2 $value)(mode_tile \"h2\" (boole 1 1 0))(mode_tile \"h1\" (boole 1 1 (atoi val2)))" )
(defun OnOK ()
(cond ((= (get_tile "rad1") 1) (setq size1 (nth (atoi (get_tile "h1")) lst1)))
((= (get_tile "rad2") 1) (setq size1 (nth (atoi (get_tile "h2")) lst2)))
)
(setq done t)
(done_dialog)
)
(action_tile "accept""(OnOK)")
(action_tile "cancel" "(setq done nil)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(print size1)
(princ)
)
get\u tile函数的值将是一个字符串,因此我们应该用一个字符串而不是像这样的数字来测试它。。
6 谢谢你的时间和宝贵的帮助。
非常感谢。 不客气,塔瓦!
页:
[1]