;;;Writes comparison of two autolisp (or other ASCII) files to a file named -. ;;;in the same folder as . ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 8-10-2006 ;;;> EDITED: 08-10-2006 ;;; (defun c:comparefiles ( / path#1 open#1 read#1 file#1_lst cnt#1 path#2 open#2 read#2 file#2_lst cnt#2 princ_cnt#1 princ_cnt#2) (setq old_compfiles_error *error*) (setq *error* compfiles_error) (setq file#1 (getfiled "First file to compare" (if file#1 file#1 "") "lsp;_ls" 4)) (setq path#1 (dos_splitpath file#1)) (setq file#2 (getfiled "First file to compare" (if file#2 file#2 (IF path#1 (CADDR path#1) "")) "lsp;_ls" 4)) (setq path#2 (dos_splitpath file#2)) (if (and file#1 file#2) (progn (setq open#1 (open file#1 "r")) (while (setq read#1 (read-line open#1)) (setq file#1_lst (append file#1_lst (list read#1))) ) (close open#1) (setq open#2 (open file#2 "r")) (while (setq read#2 (read-line open#2)) (setq file#2_lst (append file#2_lst (list read#2))) ) (close open#2) (setq cnt#1 1) (setq compout (open (strcat (car path#1)(cadr path#1)(caddr path#1)"-"(caddr path#2)(cadddr path#1)) "w")) (princ"\n\nThe following lines in: \"" compout) (princ file#1 compout) (princ "\"\n do not exist in: \"" compout) (princ file#2 compout) (princ "\"\n" compout) (foreach n file#1_lst (if (member n file#2_lst) nil (progn (if (and princ_cnt#1 (eq princ_cnt#1 (1- cnt#1))) nil (if (and princ_cnt#1 (< princ_cnt#1 (1- cnt#1))) (princ "\n" compout) ) ) (setq princ_cnt#1 cnt#1) (COND ((< cnt#1 10)(princ "\n " compout)) ((< cnt#1 100)(princ "\n " compout)) ((< cnt#1 1000)(princ "\n " compout)) ((< cnt#1 10000)(princ "\n " compout)) ((< cnt#1 100000)(princ "\n" compout)) ) (princ cnt#1 compout) (princ ": " compout) (princ n compout) (princ) ) ) (setq cnt#1 (1+ cnt#1)) ) (setq cnt#2 1) (princ"\n\nThe following lines in: \"" compout) (princ file#2 compout) (princ "\"\n do not exist in: \"" compout) (princ file#1 compout) (princ "\"\n" compout) (foreach n file#2_lst (if (member n file#1_lst) nil (progn (if (and princ_cnt#2 (eq princ_cnt#2 (1- cnt#2))) nil (if (and princ_cnt#2 (< princ_cnt#2 (1- cnt#2))) (princ "\n" compout) ) ) (setq princ_cnt#2 cnt#2) (COND ((< cnt#2 10)(princ "\n " compout)) ((< cnt#2 100)(princ "\n " compout)) ((< cnt#2 1000)(princ "\n " compout)) ((< cnt#2 10000)(princ "\n " compout)) ((< cnt#2 100000)(princ "\n" compout)) ) (princ cnt#2 compout) (princ ": " compout) (princ n compout) (princ) ) ) (setq cnt#2 (1+ cnt#2)) ) (close compout) ) ) (setq *error* old_compfiles_error) (princ) ) (defun compfiles_error (msg / ) (princ "\nERROR: ") (princ msg) (if open#1 (close open#1)) (if open#2 (close open#2)) (if compout (close compout)) (setq *error* old_compfiles_error) (princ) )