霸蛮写出来了,但是您应该达不到自己的目标,方式错了,您把自己的问题好好捋捋,重新提问吧
按例题替换文本中字符串代码如下:
- (defun c:test (/ f fn lst n tmp tmp1)
- (setq lst (list '("d1" 200) '("d2" 300) '("d3" 400)))
- (setq fn "d:\\插件\\1.txt"
- f (open fn "r")
- tmp1 nil
- )
- (while (setq tmp (read-line f))
- (setq tmp1 (cons (read tmp) tmp1))
- )
- (close f)
- ;;;(vl-file-delete fn)
- (setq tmp1 (reverse tmp1)
- f (open fn "w")
- )
- (foreach n lst
- (setq
- tmp1 (mapcar '(lambda (x) (subst n (assoc (car n) x) x)) tmp1)
- )
- )
- (foreach n tmp1
- (write-line
- (vl-princ-to-string
- (mapcar '(lambda (x) (list (strcat """ (car x) """) (cadr x)))
- n
- )
- )
- f
- )
- )
- (close f)
- )
|