@Sharper Hi - I've been on Holiday but didn't forget you , Please give this code a try. I minimally tested it with the example code you posted and it worked. Alter the path and file extension to suit you needs in the UPDATEGC command. Just in case - I recommend you backup your Gcode file before using.
;; Escape Wildcards - Lee Mac
;; Escapes wildcard special characters in a supplied string
(defun LM:escapewildcards ( str )
(if (wcmatch str "*[-#@.*?~`[`,]*,*`]*")
(if (wcmatch str "[-#@.*?~`[`,]*,`]*")
(strcat "`" (substr str 1 1) (LM:escapewildcards (substr str 2)))
(strcat (substr str 1 1) (LM:escapewildcards (substr str 2)))
)
str
)
)
(defun ReplaceCodes (file kw1 kw2 / flg fp ln ls n)
(if (and file (setq file (findfile file)))
(progn
(setq fp (open file "r") flg nil)
(while (setq ln (read-line fp))
(if (wcmatch ln (strcat "*" (LM:escapewildcards kw1) "*"))
(setq ln (vl-string-subst kw2 kw1 ln)
ls (cons ln ls) flg T
)
(setq ls (cons ln ls))
)
)
(close fp)
(if (and ls flg)
(progn
(setq fp (open file "w")
ls (reverse ls)
n 0
)
(repeat (length ls)
(write-line (nth n ls) fp)
(setq n (1+ n))
)
(close fp)
(princ "\nFile Updated.")
)
(princ "\nNo lines found in file that match the pattern. ")
)
)
(princ "\nFile Not found.")
)
(princ)
)
(defun c:UpdateGC ()
(if (setq fil (getfiled "Select Gcode File to Update" "C:\\Myfolder\\" "gco" 4))
(ReplaceCodes fil "Qualify(1.000,0.0,0.0)" "Qualify(1.000,0.0,0.035)")
)
)
Thanks to Lee Mac for the "Escape Wildcards" code.