|
;;;================== ;;;= 读取文件到表中 = ;;;================== (defun fcp::readfile (filename / fileobj str outlist) (setq outlist nil) (if (findfile filename) (progn (setq fileobj (open filename "r") str (read-line fileobj) ) (while (/= str nil) (setq outlist (append outlist (list str)) str (read-line fileobj) ) ) (close fileobj) ) (alert (strcat "文件不能打开!请查询\n" filename "这个文件是否存在?" ) ) ) outlist ) ;;;======================== ;;;= 将表中的内容写入文件 = ;;;======================== (defun fcp::writefile (filename inlist intype / fileobj outlist) (setq outlist nil fileobj (open filename intype) ) (if fileobj (progn (mapcar '(lambda (x) (write-line x fileobj)) inlist) (close fileobj) (setq outlist t) ) (alert (strcat "文件不能打开!请查询\n" filename "文件名是否正确?" ) ) ) outlist ) ;;;============ ;;;= 重写文件 = ;;;============ (defun fcp::writefilew (filename inlist) (fcp::writefile filename inlist "w") ) ;;;============ ;;;= 改写文件 = ;;;============ (defun fcp::writefilea (filename inlist) (fcp::writefile filename inlist "a") ) |