;;; ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: ;;;> EDITED: 05-27-2001 ;;; (defun C:srext () (setq orig_lst nil) (setq new_lst nil) (setq ftoch (getfiled "Select File" "C:\\~coopfra\\~pfrancis\\" "htm" 4)) (setq srch_str (ustr 1 "String to search for" (if srch_str srch_str "") T)) (setq repl_str (ustr 0 "String to replace it" (if repl_str repl_str "") T)) (setq opn_ftc (open ftoch "r")) (setq rd_line (read-line opn_ftc)) (setq orig_lst (list rd_line)) (while (setq rd_line (read-line opn_ftc)) (setq orig_lst (append orig_lst (list rd_line))) ) (setq new_lst orig_lst) (foreach n orig_lst (if (wcmatch n (strcat "*" srch_str "*")) (progn (setq count 1) (while (not (wcmatch (substr n count) (strcat srch_str "*"))) (setq count (1+ count)) ) (if (> count 1) (setq new_str (strcat (substr n 1 (1- count)) repl_str (substr n (+ count (strlen srch_str))))) (setq new_str (strcat repl_str (substr n (1+ (strlen srch_str))))) ) (setq new_lst (subst new_str n new_lst)) ) ) ) (close opn_ftc) (if (eq orig_lst new_lst) nil (progn (while (not (setq opn_ftc (open ftoch "w"))) ) (foreach n new_lst (write-line n opn_ftc) ) ) ) (close opn_ftc) (princ) )