打包到vlx中的a.txt文件怎么打开?
打包到vlx中的a.txt文件,不知道路径,如何open? 我曾经也为这个问题困扰过,vl-get-resource 虽然可以读出打包到VLX中的文本文件,但是读出的文本文件是不能直接使用的,必须要进行转换,才能使用,在网上搜索了很久,找到了以下代码,完美解决了该问题,希望能帮到你。(defun text_make (/ fn fn2 fn_lst n m fn_txt)(setq fn2 (open text_name "w"));text_name为要生成的文本文件
(setq fn (vl-get-resource text-name));text-name为打包到vlx中的文本名,(不要扩展名)
(strlen fn)
(setq fn_lst (dxf_string fn "\r\n"));根据读出的文本生成字符串表
(setq n (length fn_lst))
(setq m 0)
(while (< m n)
(setq fn_txt (nth m fn_lst))
(write-line fn_txt fn2)
(setq m (1+ m))
)
(close fn2)
)
(defun dxf_string (sstring sstr / n1 n2 m2 str_1)
(setq string_list '())
(setq n1 (strlen sstring))
(setq n2 (strlen sstr))
(while (setq m2 (vl-string-search sstr sstring))
(setq str_1 (substr sstring 1 m2))
(setq sstring (substr sstring (+ 1 m2 n2)))
(if (/= str_1 "")
(setq string_list (cons str_1 string_list))
)
(if (= (substr sstring 1 n2) sstr)
(setq string_list (cons "" string_list))
)
)
(if (/= sstring "")
(setq string_list (cons sstring string_list))
)
(reverse string_list)
)
用vl-get-resource读取 wangph 发表于 2013-1-10 21:50
用vl-get-resource读取
谢谢呀,如果有个例子就好了。。。。 好像读出的是二进制,不是字符,不知道有没人碰到过。。。。 可以看帮助呀:
Examples
Assume the getres.vlx file contains a LISP program defining a function named print-readme, and a text file named readme.txt. The print-readme function is defined as follows:
(defun print-readme ()
(princ (vl-get-resource "readme"))
(princ)
)
很好,学习了! 谢谢了。。。。 hpy 发表于 2013-1-11 09:44 static/image/common/back.gif
我曾经也为这个问题困扰过,vl-get-resource 虽然可以读出打包到VLX中的文本文件,但是读出的文本文件是不能 ...
我刚试验过,打包进VLX中的文本文件是可以直接读写出来的 wangph 发表于 2013-1-11 10:18 static/image/common/back.gif
我刚试验过,打包进VLX中的文本文件是可以直接读写出来的
不知怎的,反正我打包到VLX中的文本文件,直接读出的文本文件通篇都带有"\r\n"这样的格式符号,没法直接使用,必须用上面的代码把"\r\n"去掉,然后按打包前的格式重新生成文本文件。
页:
[1]
2