本帖最后由 hbgsw 于 2015-11-6 11:53 编辑
问题点:每次生成临时DCL的时候,格式基本都是固定的,所以想弄个lisp,直接将做好的DCL转换为临时DCL,论坛找了一圈也没有找到合适的程序,
所以打算自己写个,但是到了laybel和key 后面的引号" "处卡住了,不知道如何判断填写 \ ,请各位高手支援下,谢谢!
DCL格式:
label = "注册" ;
key = "c03" ;
临时DCL格式:
(write-line " label =\"注册\" ;" f)
(write-line " key =\"c03\" ;" f)
子程序如下:
 - (defun readfile (file / fn str txt )
- ;路径文件名,结果返回为list ;(strcat txtdir "formset.txt")
- (if (setq file (findfile file))
- (progn
- (setq fn (open file "r"))
- (setq str nil)
- (if (not (setq txt (read-line fn))) ;判断文件是否为空
- (progn (princ "\n 文件为空,readfile 文件失败") (exit))
- )
- (cond ((= (substr txt 1 1) ";") ;读取配置文件为表,
- (while (setq txt (read-line fn))
- (if (and (/= txt "")
- (/= (substr txt 1 1) ";")
- (setq txt (read txt))
- )
- (setq str (cons txt str))
- )
- )
- )
- ((= (substr txt 1 2) "/*") ;读取DCL文件,并转换为临时对话框格式,对话框采用飞诗格式,或第一行/* 格式固定。
- (while (and (setq txt (read-line fn))
- (/= txt "")
- )
- (setq txt (strcat "(write-line" "\"" txt "\"" " f)"))
- (setq str (cons txt str))
- )
- )
- (t
- (alert "\n readfile 文件格式不正确")
- )
- )
- (close fn)
- (princ)
- (setq str (reverse str))
- )
- (progn (princ "\n 文件不存在或文件错误,readfile读取文件失败")
- (exit)
- )
- )
- )
- (if (not lj)
- (setq lj "C:/Users/31000/Desktop/")
- )
- (setq txt (readfile (getfiled "选择DCL文件" lj "DCL" 2)))
- (setq fname (vl-filename-mktemp "temp.txt")
- f (open fname "w")
- )
- (foreach x txt
- (write-line x f)
- )
- (close f)
- (startapp "notepad.exe" fname)
- (command "delay" 600)
- (princ)
- (vl-file-delete fname)
|