代码改变世界

AutoLISP对话框DCL关于LIST_BOX应用示例

2011-04-25 16:59  精诚所至 金石为开  阅读(2608)  评论(0编辑  收藏  举报

AutoLISP对话框DCL关于LIST_BOX应用示例,DCL对话框代码如下。

dia7a:dialog {
    label = "列表框示例" ;
    :list_box {
        height = 10 ;
        key = "klist" ;
        label = "词库选单" ;
        width = 30 ;
    }
    :edit_box {
        key = "wordstr" ;
        label = "词库" ;
    }
    spacer_1;
    ok_cancel;
}

LSP文件代码如下。

(defun c:dia7a ()
    (setvar "cmdecho" 0)
    (setq word_list '("亚洲"
              "中国"
              "北京"
              "天津"
              "上海"
              "广州"
              "重庆"
              "四川"
              "河南"
              "郑州"
              "开封"
              "武汉"
              "河北"
              "江西"
              "甘肃"
             )
    )
    (dcl_dia7a)
    (prin1)
)
(defun dcl_dia7a ()
    (setq dcl_id (load_dialog "dia7a"))
    (new_dialog "dia7a" dcl_id)
    (start_list "klist")
    (mapcar 'add_list word_list)
    (end_list)
    (action_tile "klist" "(sub_klist $value)")
    (action_tile "accept" "(ok_dia7a) (done_dialog 1)")
    (setq dd (start_dialog))
    (if    (= dd 1)
    (progn
        (setvar "cmdecho" 1)
        (command "text" pause 0 wordstr)
        (setvar "cmdecho" 0)
    )
    )
)
(defun sub_klist (vvs)
    (set_tile "wordstr" (nth (atoi vvs) word_list))
)
(defun ok_dia7a    ()
    (setq wordstr (get_tile "wordstr"))
)

代码完。