daiguafan 发表于 2011-3-14 14:16:57

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

本帖最后由 daiguafan 于 2011-3-17 16:47 编辑

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





Gu_xl 发表于 2011-3-14 14:23:33

回复 daiguafan 的帖子

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

lee50310 发表于 2022-2-20 21:11:42

本帖最后由 lee50310 于 2022-2-21 10:48 编辑

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

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

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

如圖所示:

365724661 发表于 2022-2-20 17:17:31

daiguafan 发表于 2011-3-18 12:05
回复 ZZXXQQ 的帖子

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


listbox增加删除的解决了么

daiguafan 发表于 2011-3-14 14:26:28

回复 Gu_xl 的帖子

谢谢斑竹,我研究下,非常感谢您及时的答复

daiguafan 发表于 2011-3-14 14:42:41

回复 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"))
)

Gu_xl 发表于 2011-3-14 14:54:45

回复 daiguafan 的帖子


(defun c:tt (/ *valist* addl DCL_1)
(defun addl ()
(setq *valist* (append *valist* (list (get_tile "v1"))))
    (if *valist*
    (progn
(start_list "list1")
(foreach n *valist*
    (add_list n)
)
(end_list)
)
    )
)
(SETQ DCL_1 (LOAD_DIALOG "test.dcl"))
(NEW_DIALOG "test" DCL_1)
(ACTION_TILE "accept" "(DONE_DIALOG)")
(action_tile "add" "(addl)")
(action_tile "cancel" "(cancel)")

(START_DIALOG)
(UNLOAD_DIALOG DCL_1)

)

daiguafan 发表于 2011-3-14 15:03:27

回复 Gu_xl 的帖子

万分感谢
呵呵
呵呵

xyp1964 发表于 2011-3-14 20:43:34

也来一个:;; 需要e派工具箱的支持: http://xyp1964.ys168.com
(defun c:tt (/ ilst)
(defun abu ()
    (xyp-Dcl-Gettile '("t1"))
    (if        (not (member t1 lst-tx))
      (setq lst-tx (cons t1 lst-tx))
    )
    (xyp-Show-List "li" lst-tx)
)
(defun ali ()
    (xyp-Dcl-Gettile '("li"))
    (alert (nth (atoi li) lst-tx))
)
(xyp-initSet '(li t1) '("0" ""))
(setq        lst-tx (if lst-tx
               lst-tx
               '()
             )
        ilst   '(("li" "" "list" "lst-tx" "8" "10" "(ali)")
               ":row{"
               ("t1" "文本" "str" "12")
               ("bu" "添加" "button1" "(abu)")
               "}"
               "spacer;"
                )
)
(xyp-Dcl-Init Ilst "【测试】" t)
(princ)
)

daiguafan 发表于 2011-3-16 11:14:28

回复 xyp1964 的帖子

院长这个不厚道啊,要你的专门函数库支持

daiguafan 发表于 2011-3-17 10:06:50

本帖最后由 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)
)




daiguafan 发表于 2011-3-17 15:51:44

最新修改了下,希望大虾帮个忙
页: [1] 2 3
查看完整版本: 【求助】dcl中的list如何完成增加,删除,导入(已经调试成功),修改,清空等