2 Replies Latest reply on Jan 8, 2014 5:34 PM by XH.XH

    Using app.findGrep() and app.changeGrep() consecutively

    HankBrutowsky1

      I have a script that should find and replace predefined terms and mark the changes visually on a separate layer. 

       

      The process basically works in two steps: 

      1. Loop through a list of expressions, look for every expression with app.findGrep() and insert Note-Markers at the beginning and at the end of a match. 
      2. Loop through the same list again and find & replace with corresponding terms of another predefined list, using app.changeGrep(). After that, use the positions of the markers to draw rectangles on a new layer in order to visualize the changes. 

       

      The problem is that even though Step 1 works fine (marks show up at their correct positions), step 2 doesn't seem to do anything, unless I change the findWhat parameter to an expression that hasn't been used already in the list of step 1. 

       

      So, my guess is that Indesign somehow caches all performed searches and prevents any further look-ups with those expressions. 

       

      However, if I use the standard find&replace form after the execution of the script, I can still find any expression from the list without any issues. Can anyone see how I can solve this issue? 

       

      Thanks for any help!

      Sam