;;; ;;; ;;; Author: ;;; Henry C. Francis ;;; 425 N. Ashe St. ;;; Southern Pines, NC 28387 ;;; ;;; All rights reserved. ;;; ;;; Copyright: ;;; Edited: (DEFUN c:searchfiles () (SETQ ffstrlst nil) (SETQ srchpath (ustr 1 "Search path" srchpath T)) (SETQ srchfile (ustr 1 "File(s) to search (wildcard for multiple files)" srchfile T ) ;_ end of ustr ) ;_ end of setq (SETQ srchstr (ustr 1 "String to search for" srchstr T)) (SETQ foundfiles (DOS_DIR (STRCAT srchpath srchfile))) (FOREACH n foundfiles ;;; (princ (strcat "\nOpening " n " to search. ")) (IF (SETQ opnff (OPEN (STRCAT srchpath n) "r")) (PROGN ;;; (princ "Opened! ") ;;; (princ) (SETQ rlcnt 1) (WHILE (SETQ rlopnff (READ-LINE opnff)) (IF (WCMATCH (STRCASE rlopnff) (STRCASE srchstr)) (PROGN (SETQ ffstrlst (APPEND ffstrlst (LIST (LIST n rlcnt rlopnff))) ) ;_ end of setq ;;; (princ (strcat "\n\tLine no. " (itoa rlcnt) " matched search string! ")) ;;; (princ) ) ;_ end of progn ) ;_ end of if (SETQ rlcnt (1+ rlcnt)) ) ;_ end of while (CLOSE opnff) ) ;_ end of PROGN (PRINC (STRCAT "Open " srchpath n " Failed! ")) ) ;_ end of IF ) ;_ end of foreach (IF (AND ffstrlst (SETQ fstrout (OPEN (STRCAT srchpath "search results.txt") "w")) ) ;_ end of AND (PROGN (FOREACH n ffstrlst (SETQ oldcfname cfname cfname (CAR n) ) ;_ end of SETQ (IF (EQ oldcfname cfname) NIL (PROGN (WRITE-LINE (STRCAT "\n" cfname) fstrout) (PRINC (STRCAT "\n\n" cfname)) ) ;_ end of PROGN ) ;_ end of IF (COND ((EQ (STRLEN (STRCAT "Line " (ITOA (CADR n)))) 6) (SETQ lnostr (STRCAT "\tLine " (ITOA (CADR n)) " ")) ) ((EQ (STRLEN (STRCAT "Line " (ITOA (CADR n)))) 7) (SETQ lnostr (STRCAT "\tLine " (ITOA (CADR n)) " ")) ) ((EQ (STRLEN (STRCAT "Line " (ITOA (CADR n)))) 8) (SETQ lnostr (STRCAT "\tLine " (ITOA (CADR n)) " ")) ) ((EQ (STRLEN (STRCAT "Line " (ITOA (CADR n)))) 9) (SETQ lnostr (STRCAT "\tLine " (ITOA (CADR n)) " ")) ) ) ;_ end of COND (WRITE-LINE (STRCAT lnostr "\t" (CADDR n)) fstrout) (PRINC (STRCAT "\n" lnostr "\t" (CADDR n))) (PRINC) ) ;_ end of foreach ) ;_ end of progn (COND (ffstrlst (PRINC (STRCAT "\nUnable to open " srchpath "\"search results.txt\" for output! " ) ;_ end of strcat ) ;_ end of PRINC ) (fstrout (PRINC "\nNo matches found! ") ) ) ;_ end of COND ) ;_ end of IF (PRINC) ) ;_ end of defun ;|«Visual LISP© Format Options» (72 2 40 2 T "end of " 60 9 2 0 0 T T nil T) ;*** DO NOT add text below the comment! ***|;