尝试存储最后一个文件夹
大家好,我试图让autolisp命令getfield转到我再次运行lisp时它保存文件的最后一个文件夹。
我有默认的目录设置,但我一直在研究如何让它返回到上次运行autolisp代码时所在的目录。
(setq file (open (getfiled "specify output file" "C:/data08/" "xyz" 1) "w"))
基本上这就是我现在正在使用的,所有它都会转到C:\data08\
我真的很困惑,有没有办法让变量保存命令保存文件的最后一个目录,然后在再次运行autolisp时调用该变量?还是有更简单的方法?
感谢阅读,
卡布拉姆 为路径创建一个全局变量,并将其替换为“C:/data08/” 谢谢hendie,
由于某种原因,我试图让它工作。GetField不喜欢C:\\data08\\t只有在我使用C:\\data08\\t时才能工作。
有什么方法可以让getfield命令使用两个,或者我可以将两个转换成一个斜杠吗? 我认为可以使用双反斜杠存储变量:
C: 数据08\\\\
不确定这是否有效。。。 我会尽力解释清楚的
GetField无法读取c:\\Data08\\it give me this error
; 错误:错误函数:“C:\\Data08\”
GetField可以读取c:\Data08\
Autolisp自动将所有\转换为\\
我试图使用vl string subst命令将\\更改为\它不工作的atm,但我会继续。
谢谢你们的帮助,伙计们,这让我很困惑 好吧,我成功了,但不知道为什么
(setq file (open (getfiled "specify output file" path1 "xyz" 1) "w"))
这个不行!
(setq file (open (getfiled "specify output file" path1 "xyz" 17) "w"))
这是我添加的
不知道为什么它会起作用,但它确实起了作用。哈哈,伙计,我对这件事很糟糕。谢谢大家的帮助 也许这也能有所帮助
它将记住上次使用的搜索路径
;Date : 19:11 19/01/2009
;;Add to start of routine
;;Load active x support
(vl-load-com)
;;Set the default directory for the first time the routine is loaded
(or dir (setq dir "C:/data08/")) ;;"C:/data08/"can be changed to any path as a default
;;Verify that the directory is a valid one otherwise set it to the C drive
(or (vl-file-directory-p dir)(setq dir "C:/"))
(setq fname(getfiled "specify output file" dir "xyz" 1))
;(setq file (open fname "w"))
;(close file)
;;Add to end of routine
;;Store the path for the next time the routine is run
(setq dir (vl-filename-directory fname))
恐怕我不确定为什么Getfield在阅读路径时遇到问题。。
-杰米 变量path1是否可能是带有文件名的路径?
例如:C:/data08/调查。xyz公司
在GetField中添加16(第4位)似乎会去掉文件名并只搜索路径。
该错误可能是由于将路径和文件名传递给getfield并将标志设置为1引起的 Jammie的观点很好,代码也很好。 嗯,谢谢你的帮助,jammie,我会看看是否能用上你的代码,它比我的代码干净多了,哈!它很好地记住了路径特征。
对于路径,我认为它不会包含文件名。我在命令提示符下手动输入路径,这可能与此有关。
可能是它从路径中删除了final\\s,这可能就是问题所在。
无16位
e、 g.C:/data08/
带16位
e、 g.C:/data08
我只是在猜测它为什么起作用我真的不知道
页:
[1]
2