lisp routin的帮助
嗨,伙计们,我需要打开一个名为test的文件。txt,并为此文件的每一行添加1-find "A" in the file and replace with "AA".
2-added string "xxxxxxxx" in ahead of each line.
3-added "yyyyyy" in the end of each line .
感谢任何帮助8) 单向
(setq a (open "X:\\Your\\Path\\test.txt" "r"))
(while (setq b (read-line a))
(setq c (cons b c))
);; while
(close a)
(foreach x c
(if (wcmatch x "*A*")
(progn
(setq i 0)
(while (setq i (vl-string-search "A" x i))
(setq x (vl-string-subst "AA" "A" x i))
(setq i (+ i 2))
);; while
);; progn
);; if
(setq x (strcat "xxxxxxxx" x "yyyyyy")
d (cons x d)
);; setq
);; foreach
(setq a (open "X:\\Your\\Path\\test.txt" "w"))
(foreach x d
(write-line x a)
);; foreach
(close a)
希望有帮助
亨里克 所以XXXXX hmsilva
第2、3项操作OK,但第1项表现不好,且“A”没有变化,
你确定吗?
具有
A测试e测试AA A
测试B A
测试A B和C
运行代码后
XXXXXXXX AA测试e测试AAAA AA AAAYYYYY
XXXXXXXX测试B AAYYYYY
XXXXXXXX测试AA B和CYYYYY
亨里克 好的,再次测试,一切正常
thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:) 不客气,霍辛
很高兴我能帮忙
亨里克 如果我在bat文件中有这个dos命令,有没有办法更改为lisp rotine?///?
dir/b/oN/A-H *.LSP >uu(LSP).LSP
在这里搜索这两个lisp命令getfield和Findfile,你会发现一些例子可以做你想做的事情,我知道你想做的。lsp A-H您可能需要删除列表,因为我认为这两种方法将为您提供所有内容,但这很容易查看文件名的第一个字符。 hmsilva公司
一切正常,直到我想改变特殊角色”和括号 hmsilva公司
一切正常,直到我想更改特殊字符和括号
在这种情况下,lisp不匹配:?
(foreach x c
(setq x (strcat "(load "C:\\000-lisp1\\" x " " "MyLISP Failed to Load")")
d (cons x d)
);; setq
);; foreach
页:
[1]
2