明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3255|回复: 21

【求助】dcl中的list如何完成增加,删除,导入(已经调试成功),修改,清空等

  [复制链接]
发表于 2011-3-14 14:16 | 显示全部楼层 |阅读模式
本帖最后由 daiguafan 于 2011-3-17 16:47 编辑

如图所示,希望使用增加按钮就可以再list中添加输入的内容
这个应该简单,但是我完全不知道怎么处理list
希望各位帮忙谢谢斑竹帮忙
增加功能已经实现
但是现在删除
导入,清空功能我已经调试成功,没处理好的地方希望大虾们帮帮忙





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-3-14 14:23 | 显示全部楼层
回复 daiguafan 的帖子

;;;将列表值存储在*valist*中,每点击一次增加,将editbox值添加到 *valist*中,运行如下代码更新list
(start_list key)
  (foreach n *valist*
    (add_list n)
  )
  (end_list)
回复 支持 0 反对 1

使用道具 举报

发表于 2022-2-20 21:11 | 显示全部楼层
本帖最后由 lee50310 于 2022-2-21 10:48 编辑

一個來自國外論壇的類似範例 可當參考  

下載後自行研究吧!
載入後執行指令:test

功能: 1.可增加( Add>>)  ,2.刪除(Remove)  ,3.替換(Replace),
         4.上移(Move UP)   ,5.下移(Move Down)

如圖所示:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

评分

参与人数 1明经币 +1 收起 理由
365724661 + 1 很给力!

查看全部评分

发表于 2022-2-20 17:17 | 显示全部楼层
daiguafan 发表于 2011-3-18 12:05
回复 ZZXXQQ 的帖子

好像我调试的时候get-title list1 就是空的

listbox增加删除的解决了么
 楼主| 发表于 2011-3-14 14:26 | 显示全部楼层
回复 Gu_xl 的帖子

谢谢斑竹,我研究下,非常感谢您及时的答复
 楼主| 发表于 2011-3-14 14:42 | 显示全部楼层
回复 daiguafan 的帖子

我这样写了下,但是还是不对斑竹送佛送到西啊,帮忙看下,呵呵

(defun c:tt ()
(SETQ DCL_1 (LOAD_DIALOG "test"))
(NEW_DIALOG "test" DCL_1)
(ACTION_TILE "accept" "(DONE_DIALOG)")
(action_tile "add" "(addl)")
(action_tile "cancel" "(cancel)")
(START_DIALOG)
(UNLOAD_DIALOG DCL_1)

(start_list list1)
  (foreach n *valist*
    (add_list n)
  )
  (end_list)
)
(defun addl ()
(setq *valist* (get_tile "v1"))
)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-3-14 14:54 | 显示全部楼层
回复 daiguafan 的帖子

  1. (defun c:tt (/ *valist* addl DCL_1)
  2.   (defun addl ()
  3. (setq *valist* (append *valist* (list (get_tile "v1"))))
  4.     (if *valist*
  5.     (progn
  6. (start_list "list1")
  7.   (foreach n *valist*
  8.     (add_list n)
  9.   )
  10.   (end_list)
  11. )
  12.     )
  13. )
  14. (SETQ DCL_1 (LOAD_DIALOG "test.dcl"))
  15. (NEW_DIALOG "test" DCL_1)
  16. (ACTION_TILE "accept" "(DONE_DIALOG)")
  17. (action_tile "add" "(addl)")
  18. (action_tile "cancel" "(cancel)")
  19.   
  20. (START_DIALOG)
  21. (UNLOAD_DIALOG DCL_1)

  22. )

 楼主| 发表于 2011-3-14 15:03 | 显示全部楼层
回复 Gu_xl 的帖子

万分感谢
呵呵
呵呵
发表于 2011-3-14 20:43 | 显示全部楼层
也来一个:
  1. ;; 需要e派工具箱的支持: http://xyp1964.ys168.com
  2. (defun c:tt (/ ilst)
  3.   (defun abu ()
  4.     (xyp-Dcl-Gettile '("t1"))
  5.     (if        (not (member t1 lst-tx))
  6.       (setq lst-tx (cons t1 lst-tx))
  7.     )
  8.     (xyp-Show-List "li" lst-tx)
  9.   )
  10.   (defun ali ()
  11.     (xyp-Dcl-Gettile '("li"))
  12.     (alert (nth (atoi li) lst-tx))
  13.   )
  14.   (xyp-initSet '(li t1) '("0" ""))
  15.   (setq        lst-tx (if lst-tx
  16.                  lst-tx
  17.                  '()
  18.                )
  19.         ilst   '(("li" "" "list" "lst-tx" "8" "10" "(ali)")
  20.                  ":row{"
  21.                  ("t1" "文本" "str" "12")
  22.                  ("bu" "添加" "button1" "(abu)")
  23.                  "}"
  24.                  "spacer;"
  25.                 )
  26.   )
  27.   (xyp-Dcl-Init Ilst "【测试】" t)
  28.   (princ)
  29. )
 楼主| 发表于 2011-3-16 11:14 | 显示全部楼层
回复 xyp1964 的帖子

院长这个不厚道啊,要你的专门函数库支持
 楼主| 发表于 2011-3-17 10:06 | 显示全部楼层
本帖最后由 daiguafan 于 2011-3-17 16:46 编辑

麻烦各位帮帮忙啊,这个应该是不难的基本功能,呵呵
但是我就是写不对——最新由猫哥帮忙,清空命令已经解决,但是猫哥lisp水平太高,发的文件我有些看着吃力,自己写的还是存在一些问题现在就剩下删除和修改的问题没有解决了
(defun c:tt (/ addl DCL_1)
;
(SETQ DCL_1 (LOAD_DIALOG "test.dcl"))
(NEW_DIALOG "test" DCL_1)
(ACTION_TILE "accept" "(DONE_DIALOG)")
(action_tile "add" "(add0)")
(action_tile "delall" "(delist)")
(action_tile "del0" "(dell0)")
(action_tile "edit1" "(edit)")
(action_tile "input-1" "(input)")
(action_tile "cancel" "(cancel)")
;(action_tile "list1" "(inlist)")
(START_DIALOG)
(UNLOAD_DIALOG DCL_1)

)

(defun add0 ();增加
    (setq MyList (append MyList (list (get_tile "v1"))))
(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 input ();导入
;获取数据库
  (setq fname (getfiled "选择文本文件" "" "txt" 2))
  (setq FP (open fname "r"))
  (setq DATA nil)
  (WHILE (SETQ LINE (READ-LINE FP))
;将数据库中的数据存入DATA中
    (if
(and (> (strlen LINE) 0) (not (wcmatch LINE "!*")))
      (progn

(SETQ DATA (CONS LINE DATA))
      )
    )
  )
  (setq DATA (reverse DATA))
  (close FP)
  (setq MyList DATA )
   (start_list "list1" )
(princ "\n          MyList = ") (princ MyList);Erase_DV
(getstring "\nPress Enter to continue...");Erase_DV
   (mapcar 'add_list MyList)
   (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 (list ""))
          )
;=============此段代码有问题============
(defun dell0 ();删除
           (setq MyList (vl-remove (nth  (read (get_tile "List1")) MyList) 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)
)






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

(defun dell0 ();删除
           (setq MyList (vl-remove (nth  (read (get_tile "List1")) MyList) 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)
)




 楼主| 发表于 2011-3-17 15:51 | 显示全部楼层
最新修改了下,希望大虾帮个忙
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 02:17 , Processed in 0.169612 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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