不好意思,写错了一个函数,ATOI应该是ITOA。下面是更改过的程序。下面程序中加上了错误判断。另外:数据文件DATA.TXT应该放在C盘根目录下才能正确运行。- (defun c:test ()
- (IF (SETQ F_ID (OPEN "C:data.TXT" "r")) (PROGN
- (setq os (getvar "osmode"))
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (while (SETQ text0 (READ-LINE F_ID))
- (SETQ TEXTL (READ (STRCAT "(" TEXT0 ")")))
- (SETQ TL (/ (LENGTH TEXTL) 2))
- (SETQ I 0)
- (REPEAT TL
- (SETQ PP (READ (STRCAT "P" (ITOA (1+ I)))))
- (SET PP (LIST (NTH (+ I I) TEXTL) (NTH (+ 1 I I) TEXTL)))
- (SETQ I (1+ I))
- )
- (command "pline" p1 "a" "s" p2 p3 "l" p4 "a" "s" p5 p6 "l" "c")
- )
- (CLOSE F_ID)
- (setvar "osmode" os)
- (setvar "cmdecho" 1))) (princ)
- )
|