明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1873|回复: 3

如何在LSP中实现用打开文件对话框打开多个文件

[复制链接]
发表于 2005-3-27 00:16 | 显示全部楼层 |阅读模式
请教各位,如何在LSP中实现用打开文件对话框打开多个文件?我需要同时处理多个文件,需要选择这些文件。谢谢!
发表于 2005-3-27 06:42 | 显示全部楼层
这个问题以前就贴过,参考meflying编写的程序: (defun Load_dlg( / dcl_id f filename)
(setq filename (strcat (getenv "TMP")"GetFilesDialog.dcl"))
(setq f (open filename "w"))
(write-line "GetFileDialog:dialog{" f)
(write-line "label = \"文件选择\";" f)
(write-line ":text {label = \"\"; key = \"name\";}" f)
(write-line ":row{" f)
(write-line ":list_box {label = \"文件:\"; key = \"file\"; fixed_height = true; height = 18; multiple_select = true;fixed_width = true; width = 30;}" f)
(write-line ":column {" f)
(write-line ":list_box {label = \"路径:\"; key = \"dir\"; fixed_height = true; height = 16; fixed_width = true; width = 30;}" f)
(write-line ":popup_list {label = \"驱动器:\"; key = \"dev\";}}}" f)
(write-line "ok_cancel;}" f)
(close f)
(if (< (setq dcl_id (load_dialog filename)) 0) (exit))
(vl-file-delete filename)
dcl_id
)
(defun GetDevs ( / i Device Devs)
(setq i 67)
(while (vl-directory-files (setq Device (strcat (chr i) ":")))
(setq Devs (append Devs (list Device)))
(setq i (1+ i))
)
Devs
) (defun Get_Files(ns Files / f f2 fs i )
(setq i 1)
(setq f2 "")
(while (/= (setq f (substr ns i 1)) "")
(if (= f " ")
(progn
(setq fs (append fs (list (atoi f2))))
(setq f2 "")
)
(setq f2 (strcat f2 f))
)
(setq i (1+ i))
)
(setq fs (append fs (list (atoi f2))))
(mapcar '(lambda(e) (nth e Files)) fs)
) (defun Getfiles(path flag / Files)
(setq Files (vl-directory-files path nil flag))
(if Files
(setq Files (acad_strlsort Files))
)
(vl-remove "." Files)
) (defun GetParantPath (path)
(setq i 0)
(setq n (strlen path))
(while (/= (substr path (- n i) 1) "\\")
(setq i (1+ i))
)
(setq i (1+ i))
(substr path 1 (- n i))
) (defun fill_pop(key lst)
(start_list key)
(mapcar 'add_list lst)
(end_list)
) (defun Fill_All(path / dirs Files)
(fill_pop "dir" (GetFiles path -1))
(fill_pop "file" (GetFiles path 1))
) (defun Act_Dev(n Devices / Dev )
(setq Dev (nth n Devices))
(Fill_All Dev)
(set_tile "name" Dev)
Dev
) (defun Act_Dir(n path / folder)
(setq folder (nth n (GetFiles path -1)))
(if (= folder "..")
(setq path (getParantPath path))
(setq path (strcat path "\\" folder))
)
(set_tile "name" path)
(fill_all path)
path
) (defun main( / dcl_id Act Files ns Devices Directories path R)
(setq dcl_id (Load_dlg))
(if (not (new_dialog "GetFileDialog" dcl_id)) (exit))
(setq Devices (GetDevs))
(setq path (nth 0 Devices))
(fill_pop "dev" Devices)
(setq path (Act_Dev 0 Devices))
(action_tile "dev" "(setq path (Act_Dev (atoi $value) Devices))")
(action_tile "dir" "(setq path (Act_Dir (atoi $value) path))")
(action_tile "accept" "(setq ns (get_tile \"file\")) (done_dialog 1)")
(setq Act (start_dialog))
(if (and (/= ns "") (= Act 1))
(progn
(setq Files (Getfiles path 1))
(setq R (Get_Files ns Files))
)
(setq R nil)
)
(unload_dialog dcl_id)
(mapcar '(lambda(e) (strcat path "\\" e)) R)
)
 楼主| 发表于 2005-3-27 19:01 | 显示全部楼层
谢谢!我看过,可以使用。
发表于 2005-3-28 11:12 | 显示全部楼层
看看这里: http://bbs.mjtd.com/forum.php?mod=viewthread&tid=15119 我感觉飞哥编的不错,不过如果有DOS_LIB的确话,用"dos_getfilem"界面更漂亮哦,跟WINDOWS里多选文件的一样.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-6-29 12:11 , Processed in 0.189508 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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