我有一个例行程序,读取两个文件和报告,如果有差异。
数据放在文件1的“out1”和文件2的“out2”中。
作为测试,我让它读取相同的文件。它说他们不平等。
当我这样做时,它会报告“是的!!”
当我这样做时,它会报告一个“否”
有什么想法吗?
以下是完整的例行程序:
- (defun c:ctf (/ fil fl i mycount out1 out2 rec)
- ;; String to List - Lee Mac
- ;; Separates a string using a given delimiter
- ;; str - [str] String to process
- ;; del - [str] Delimiter by which to separate the string
- ;; Returns: [lst] List of strings
- (defun lm:str->lst (str del / pos)
- (if (setq pos (vl-string-search del str))
- (cons (substr str 1 pos) (lm:str->lst (substr str (+ pos 1 (strlen del))) del))
- (list str)
- )
- ) ; End of lm:str->lst
- ; ===========================================================================================================
- ; Read File 1
- (setq fl nil)
- (setq fil nil)
- (if (setq fl (open "C:\\Users\\ggleason\\Documents\\CADWorx\\CADWorx.Projects\\Exxon.Joliet.2015-151\\IsoLayers\\ExxonMobil.Iso.Border.Acad.v.2007.dwg.txt" "r"))
- (progn
- (setq mycount 0)
- (while (setq fil (read-line fl))
- (setq mycount (1+ mycount))
- ; SYNTAX: (princ "\nMy Name is \nJohn")(princ)
- ; (princ mycount)(princ "\n")
- (setq out1 (cons (lm:str->lst fil "\t") out1))
- ) ; End of "While" loop
- (close fl)
- (princ (strcat (itoa mycount) " records read in File 1\n"))
- )
- ) ; End of "If" statement for File 1
- ;; Reverse results to put them in correct order
- (setq out1 (reverse out1))
- ; End of File 1
- ; ===========================================================================================================
- ; Read File 2
-
- (setq fl nil)
- (setq fil nil)
- (if (setq fl (open "C:\\Users\\ggleason\\Documents\\CADWorx\\CADWorx.Projects\\Exxon.Joliet.2015-151\\IsoLayers\\ExxonMobil.Iso.Border.Acad.v.2007.dwg.txt" "r"))
- (progn
- (setq mycount 0)
- (while (setq fil (read-line fl))
- (setq mycount (1+ mycount))
- ; SYNTAX: (princ "\nMy Name is \nJohn")(princ)
- ; (princ mycount)(princ "\n")
- (setq out2 (cons (lm:str->lst fil "\t") out2))
- ) ; End of "While" loop
- (close fl)
- (princ (strcat (itoa mycount) " records read in File 2\n"))
- )
- ) ; End of "If" statement for File 2
- ;; Reverse results to put them in correct order
- (setq out2 (reverse out2))
- ; End of File 2
- ; ===========================================================================================================
- ; SYNTAX: (if (= 1 3) "YES!!" "no.")
- (if (= out1 out2)
- (princ "\nYES!!")
- (princ "\nno.")
- )
- (princ "\n ------------------------------------------------")
- (princ "\n")
- (princ out1)
- (princ "\n ------------------------------------------------")
- (princ "\n")
- (princ out2)
- (princ "\n ------------------------------------------------")
- (princ)
- ) ; End of c:ctf
Greg |