明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3775|回复: 9

[求助]用getfiled 命令一次是否能否选多个文件?

[复制链接]
发表于 2004-1-7 08:01 | 显示全部楼层 |阅读模式
请问用getfiled 命令一次是否能否选多个文件?

本帖被以下淘专辑推荐:

发表于 2004-1-7 12:41 | 显示全部楼层
好像不能,呵呵
发表于 2004-1-7 13:45 | 显示全部楼层
列出给定目录中的所有文件
(vl-directory-files [directory pattern directories])


;;选择目录
(WHILE (NOT (SETQ shfolder (VLAX-INVOKE-METHOD (VLAX-CREATE-OBJECT "Shell.Application")
                                               'browseforfolder
                                               0
                                               "选择要插入的目录:"
                                               1
                           )
            )
       )
)
 楼主| 发表于 2004-1-7 14:33 | 显示全部楼层
但是我只想选择目录中的部分文件
发表于 2004-1-7 17:19 | 显示全部楼层
本帖最后由 作者 于 2004-12-18 9:01:34 编辑

虽然感觉象很老的操作系统,不过DCL的功能我暂时也就挖掘了这些
主函数:main,返回选中文件列表
  1. (defun  Load_dlg(  /  dcl_id  f  filename)
  2.     (setq  filename  (strcat  (getenv  "TMP")"GetFilesDialog.dcl"))
  3.     (setq  f  (open  filename  "w"))   
  4.     (write-line  "GetFileDialog:dialog{"  f)
  5.     (write-line  "label  =  "文件选择";"  f)
  6.     (write-line  ":text  {label  =  "";  key  =  "name";}"  f)
  7.     (write-line  ":row{"  f)
  8.     (write-line  ":list_box  {label  =  "文件:";  key  =  "file";  fixed_height  =  true;  height  =  18;  multiple_select = true;fixed_width  =  true;  width  =  30;}"  f)
  9.     (write-line  ":column  {"  f)
  10.     (write-line  ":list_box  {label  =  "路径:";  key  =  "dir";  fixed_height  =  true;  height  =  16;  fixed_width  =  true;  width  =  30;}"  f)
  11.     (write-line  ":popup_list  {label  =  "驱动器:";  key  =  "dev";}}}"  f)
  12.     (write-line  "ok_cancel;}"  f)
  13.     (close  f)
  14.     (if  (<  (setq  dcl_id  (load_dialog  filename))  0)  (exit))
  15.     (vl-file-delete  filename)
  16.     dcl_id
  17. )
  18. (defun  GetDevs  (  /  i  Device  Devs)
  19.     (setq  i  67)
  20.     (while  (vl-directory-files  (setq  Device  (strcat  (chr  i)  ":")))
  21.         (setq  Devs  (append  Devs  (list  Device)))
  22.         (setq  i  (1+  i))
  23.     )
  24.     Devs
  25. )
  26. (defun  Get_Files(ns  Files  /  f  f2  fs  i  )
  27.     (setq  i  1)
  28.     (setq  f2  "")
  29.     (while  (/=  (setq  f  (substr  ns  i  1))  "")
  30.         (if  (=  f  "  ")
  31.             (progn
  32.   (setq  fs  (append  fs  (list  (atoi  f2))))
  33.   (setq  f2  "")
  34.             )
  35.             (setq  f2  (strcat  f2  f))
  36.         )
  37.         (setq  i  (1+  i))
  38.     )
  39.     (setq  fs  (append  fs  (list  (atoi  f2))))
  40.     (mapcar  '(lambda(e)  (nth  e  Files))  fs)
  41. )
  42. (defun  Getfiles(path  flag  /  Files)
  43.     (setq  Files  (vl-directory-files  path  nil  flag))
  44.     (if  Files
  45.         (setq  Files  (acad_strlsort  Files))
  46.     )
  47.     (vl-remove  "."  Files)
  48. )
  49. (defun  GetParantPath  (path)
  50.     (setq  i  0)
  51.     (setq  n  (strlen  path))
  52.     (while  (/=  (substr  path  (-  n  i)  1)  "\")
  53.         (setq  i  (1+  i))
  54.     )
  55.     (setq  i  (1+  i))
  56.     (substr  path  1  (-  n  i))
  57. )
  58. (defun  fill_pop(key  lst)
  59.     (start_list  key)
  60.     (mapcar  'add_list  lst)
  61.     (end_list)
  62. )
  63. (defun  Fill_All(path  /  dirs  Files)
  64.     (fill_pop  "dir"  (GetFiles  path  -1))
  65.     (fill_pop  "file"  (GetFiles  path  1))
  66. )
  67. (defun  Act_Dev(n  Devices  /  Dev  )
  68.     (setq  Dev  (nth  n  Devices))
  69.     (Fill_All  Dev)
  70.     (set_tile  "name"  Dev)
  71.     Dev
  72. )
  73. (defun  Act_Dir(n  path  /  folder)
  74.     (setq  folder  (nth  n  (GetFiles  path  -1)))
  75.     (if  (=  folder  "..")
  76.         (setq  path  (getParantPath  path))
  77.         (setq  path  (strcat  path  "\"  folder))
  78.     )
  79.     (set_tile  "name"  path)
  80.     (fill_all  path)
  81.     path
  82. )
  83. (defun  main(  /  dcl_id  Act  Files  ns  Devices  Directories  path  R)
  84.     (setq  dcl_id  (Load_dlg))
  85.     (if  (not  (new_dialog  "GetFileDialog"  dcl_id))  (exit))
  86.     (setq  Devices  (GetDevs))
  87.     (setq  path  (nth  0  Devices))
  88.     (fill_pop  "dev"  Devices)
  89.     (setq  path  (Act_Dev  0  Devices))
  90.     (action_tile  "dev"  "(setq  path  (Act_Dev  (atoi  $value)  Devices))")
  91.     (action_tile  "dir"  "(setq  path  (Act_Dir  (atoi  $value)  path))")
  92.     (action_tile  "accept"  "(setq  ns  (get_tile  "file"))  (done_dialog  1)")
  93.     (setq  Act  (start_dialog))
  94.     (if  (and  (/=  ns  "")  (=  Act  1))
  95.         (progn
  96.             (setq  Files  (Getfiles  path  1))
  97.             (setq  R  (Get_Files  ns  Files))
  98.         )
  99.         (setq  R  nil)
  100.     )
  101.     (unload_dialog  dcl_id)
  102.     (mapcar  '(lambda(e)  (strcat  path  "\"  e))  R)
  103. )


发表于 2004-1-8 10:39 | 显示全部楼层
;;dos_getfilem
Displays a resizable Windows common file open dialog box that allows for multiple file selection.

Syntax
(dos_getfilem title path filter)
Parameters
title
A string containing the dialog box title.

path
A string identifying an existing directory.

filter
A filename filter string. The filter string consists of two components: a description (for example, "Text Files"), and a filter pattern (for example, "*.TXT"). Multiple filter patterns can be specified for a single item by separating the filter-pattern strings with a semicolon (for example, "*.TXT;*.DOC;*.BAK"). The components must be separated by a pipe character ("|"). The filename filter string can consist of one or more filter strings, each separated by a pipe character ("|"). The entire string must be terminated with two pipe characters ("||").


Returns
A list of filenames if successful. The first element of the list is a qualified path to the selected directory.

nil on cancel or on error.

Examples
Command: (dos_getfilem "Select files" "c:\\program files\\autocad 2002\\sample\\" "Drawing files (*.dwg)|*.dwg||")
发表于 2005-1-22 04:01 | 显示全部楼层
ok
发表于 2009-10-22 22:58 | 显示全部楼层
meflying版主水平就是高,这样的办法都能想出来
发表于 2010-12-19 19:43 | 显示全部楼层
的确是个好办法!谢谢!
发表于 2013-1-25 22:38 | 显示全部楼层
meflying版主的方法灵活好用。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 12:54 , Processed in 0.641526 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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