Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

changegrep misses final match

Return to Forums

  • Author
    Posts
    • #14328426

      I have a text frame with several paragraphs contained within “<adtext>” and “</adtext>” tags.
      I have a script that does a bunch of stuff with this text frame, including the following snippet:
      app.findGrepPreferences.findWhat=”(.+)(</adtext>)”;
      app.changeGrepPreferences.appliedParagraphStyle = styleLegalsLine2 ;
      app.changeGrepPreferences.changeTo=”$1″;
      textframe.changeGrep();
      Which changes the style of any paragraph ending in “</adtext>” to “styleLegalsLine2” and removes the “</adtext>” tag.
      Except it doesn’t change the style of the LAST paragraph or remove the tag.
      If after running the script, I immediately open the “Find/Change” dialog and click “Change All” without modifying any parameters, it gets the last one.
      What can I do to make my script change ALL instances including the last one?

    • #125753

      More info:
      The problem is somewhat intermittent: Occasionally the script works as expected, and sometimes changegrep misses the last two or even three matching paragraphs.
      This made me wonder if there’s a problem with asynchronous execution, such that the changegrep commands are running before the earlier commands are finished building the text frame.
      I moved the code snippet to the bottom of the script to execute after a couple of other things that take two or three seconds. This appeared to help–changegrep worked more often–but it’s not a “solution” because I need certain things to happen before others.
      I put the snippet back where it belongs, and inserted a “fit frame to content” command just before it:
      textframe.fit(FitOptions.FRAME_TO_CONTENT);
      This seems to have solved the issue … perhaps “fit” waits for InDesign to finish building the text frame before executing and allowing the script to continue.

Viewing 1 reply thread
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads