明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 467|回复: 7

[提问] DCL中的List如何实现增加修改删除.并读取出来?

[复制链接]
发表于 2022-11-18 15:32 | 显示全部楼层 |阅读模式
5明经币
DCL中的List如何实现增加修改删除.并读取出来?

DCL源码如下

:dialog {
    label = "SHEBEI" ;
    :list_box {
        key = "CC" ;
    }
    :edit12_box {
        key = "C1" ;
        label = "下端直径" ;
    }
    :edit12_box {
        key = "C2" ;
        label = "上端直径" ;
    }
    :edit12_box {
        key = "C3" ;
        label = "厚度" ;
    }
    :edit12_box {
        key = "C4" ;
        label = "高度" ;
    }
    :button {
        key = "add" ;
        label = "增加" ;
    }
    :button {
        key = "del" ;
        label = "删除" ;
    }
    :button {
        key = "xiu" ;
        label = "修改" ;
    }
    ok_cancel;
}



发表于 2022-11-18 16:18 | 显示全部楼层
没太搞懂啥意思。你是想在对话框操作的时候,因为某些控件的值变化而让list_box 控件里的内容发生变化么?如果想让list_box 控件里的内容发生变化,一个代码段就是:
  1. (start_list "listboxkey")
  2. (mapcar 'add_list lst)
  3. (end_list)
复制代码

你只要让另一个控件的动作能修改 lst 的值,然后再加上这一段就可以了啊。
回复

使用道具 举报

 楼主| 发表于 2022-11-19 13:36 | 显示全部楼层
vormittag 发表于 2022-11-18 16:18
没太搞懂啥意思。你是想在对话框操作的时候,因为某些控件的值变化而让list_box 控件里的内容发生变化么? ...

http://bbs.mjtd.com/forum.php?mo ... 64&highlight=dc,目的就是和这个帖子内容一样,底下输入数据后显示到上边list上,一行一行的
回复

使用道具 举报

 楼主| 发表于 2022-11-19 20:48 | 显示全部楼层
请教一下,有没有关于:dcl中的list如何完成增加,删除,导入,修改,清空等 示例学习一下呢
回复

使用道具 举报

发表于 2022-11-20 15:58 | 显示全部楼层
list控件的增加,删除,导入,修改,清空其实都一回事,都可以先修改好表,然后通过add_list实现
至于导入,比如从外部文件导入,需要先读取外部文件的数据,列成LST表即可,至于增加,删除,修改,实际上都是对lst表进行相应的处理,得到处理后的表,再用沙发上的代码把数据呈现在DLC的list控件上
回复

使用道具 举报

发表于 2022-11-20 17:03 来自手机 | 显示全部楼层
本帖最后由 wzg356 于 2022-11-20 23:25 编辑

就一个对话框要做什么,取得什么数据,输出什么
可以参考下面这个

;(autodcl+- '("a" "b" "c"))
(defun autodcl+- (lst / adkkl ff f i n id e dd)
        (defun adkkl(lst)(start_list "kkl")(mapcar 'add_list lst)(end_list))
        (setq ff (vl-filename-mktemp "temp.dcl") f (open ff "w"))
        (write-line "MY_SS: dialog{label=\"dcl+-\";" f)
    (write-line ":list_box{label=\"\";key=\"kkl\";}" f)
    (write-line ":edit_box{label=\"\";key=\"kke\";}" f)
    (write-line ":row{: button{label = \"+1\";key = \"kk+\";}" f)
    (write-line "      : button{label = \"-1\";key = \"kk-\";}}" f)
    (write-line "     ok_cancel;}" f)
    (close f)
    (setq id (load_dialog ff))
    (new_dialog "MY_SS" id)(get_tile "kke")
    (adkkl lst)
    (action_tile "kk+"
            (strcat "(if(and(<= (length lst) 10)(read(setq e(get_tile \"kke\"))))"
                "(adkkl(setq lst(cons e lst)))(alert \"非法\"))")
    )
    (action_tile "kk-" "(if(> (length lst) 1)(adkkl(setq lst(reverse(cdr(reverse lst)))))(alert \"非法\"))")
    (setq dd(start_dialog))
    (unload_dialog Id)(vl-file-delete ff)
    (if(= 1 dd)lst)
)

回复

使用道具 举报

 楼主| 发表于 2022-11-23 11:06 | 显示全部楼层
各位大虾,目前就是删除和修改调试不出来,源码如下,求指教


shebei1:dialog {
    label = "SHEBEI" ;
    :list_box {
        key = "list1" ;
    }
    :edit12_box {
        key = "C1" ;
        label = "下端直径" ;
    }
    :edit12_box {
        key = "C2" ;
        label = "上端直径" ;
    }
    :edit12_box {
        key = "C3" ;
        label = "厚度" ;
    }
    :edit12_box {
        key = "C4" ;
        label = "高度" ;
    }
    :button {
        key = "add" ;
        label = "增加" ;
    }
    :button {
        key = "del" ;
        label = "删除" ;
    }
    :button {
        key = "edit" ;
        label = "修改" ;
    }
    :button {
        key = "del0" ;
        label = "清空" ;
    }
    ok_cancel;
}


(defun c:tt (/ addl DCL_1);
(SETQ DCL_1 (LOAD_DIALOG "list.dcl"))
(NEW_DIALOG "shebei1" DCL_1)
(ACTION_TILE "accept" "(DONE_DIALOG)")
(action_tile "add" "(add0)")
(action_tile "del" "(dell0)")
(action_tile "del0" "(delist)")
(action_tile "edit" "(edit)")
(action_tile "list1" "(list1 $key $value $reason)")




  (defun list1(key value reason)
        (print key)
        (print value)
        (print reason)
       
)
;;;(set_tile "Text1" (nth (read (get_tile "List1")) List1_nums))
(action_tile "cancel" "(cancel)")
;(action_tile "list1" "(inlist)")
(START_DIALOG)
(UNLOAD_DIALOG DCL_1)
)

(defun add0 ();增加
    (setq MyList (append MyList (list (strcat(get_tile "C1")"/"(get_tile "C2")"/"(get_tile "C3")"/"(get_tile "C4")))))
(princ "\n          MyList = ") (princ MyList);Erase_DV
(getstring "\nPress Enter to continue...");Erase_DV
    (if MyList
    (progn
     (start_list "list1" )
     (foreach n MyList
     (add_list n)
     )
    (end_list)
     )
     )
)


;(defun inlist ()   
;                (start_list "List1");直列表 {"List1"} 初始化
;                (mapcar 'add_list MyList);添加列表项
;                (end_list)
;)



(defun delist ();清空
          (start_list "list1" 3 0);直列表 {"List1"} 初始化
          (mapcar 'add_list nil);添加列表项
          (end_list)
          (setq MyList nil)
          )
;=============此段代码有问题============


(defun dell0 ();删除
           (setq MyList (vl-remove  (NTH  (get_tile "List1") ) MyList))
                        (start_list "List1");直列表 {"List1"} 初始化
                        (mapcar 'add_list MyList);添加列表项
                        (end_list)
)


(defun edit ();修改

           (setq MyList (subst (get_tile "v1") (nth (read (get_tile "List1")) MyList) MyList))
                        (start_list "List1");直列表 {"List1"} 初始化
                        (mapcar 'add_list MyList);添加列表项
                        (end_list)
)








回复

使用道具 举报

 楼主| 发表于 2022-11-23 13:44 | 显示全部楼层
求各位大侠知道
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-5 16:34 , Processed in 0.263690 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表