Author Topic: replace/qreplace in a macro are leaving strings in find&replace window  (Read 3304 times)

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Attached is a macro I use to reformat log files produced by some of our software so that they are easy to read in SlickEdit.  But every time I run it, when I next use the GUI Find and Replace window, the search and replace strings I used in my macro show up as the default "Search for" and "Replace with" strings.  I was originally using "replace", and I then tried "qreplace", but they both do the same thing.  So does anyone know a way of doing a replace in a macro that does not leave behind the strings used?

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1292
  • Hero Points: 129
There are a few global macro variables that are modified by replace and qreplace (and other search functions as well) that hold all of the last searched string and flags.  What you'll need to do is to manually save and restore those global variables in your macro.  If you look and trace into the replace and qreplace in search.e, you'll see which ones get modded.  I'd suggest you'd start with saving and restoring these values at the beginning and end of your macro:

_str old_search_string;
_str old_word_re;
_str old_replace_string;
int old_search_flags;
int old_search_flags2;



StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
That fixed it.  Thank you.