2 Replies Latest reply on Jun 7, 2018 12:06 PM by Laubender

    ID CS3-5 grep notes in script fails, but in UI ok

    henkend28012856 Level 1

      Working with InDesign CS3-5 on MAC (no, not the newest system...)

       

      Hello to You,

      for months now I try to change Text with >changeGrep< in a text file that contains notes. (You can find those notes with >findText< "FEFF" or see/edit their content in the >text mode<.)

      My data is:

      <note1>X_S01002:M03<note2>Y_P00012 <+further data in line>

      <note1>X_S03302:M03<note2>Y_P00312 <+further data in line>

       

      My grep in UserInterface (cmd f) in InDesign is:

      Search for: (X_S[0-9]{5,}):([A-Z0-9]{3,})(Y_P[0-9]{5,})

      (it is set by the script below)

      The items in (see brackets) are $1 $2 $3 and they shall be in order $1 $3 $2:

      Change to: $1:$3-$2

      (so $3 has to "jump" over <note2> to the left - or better: <note2> itself jumps in front of $1)

      and the correct result is 2:

      <note1><note2>X_S01002:Y_P00012-M03 <+further data in line>

      <note1><note2>X_S03302:Y_P00312-M03 <+further data in line>

       

      To do this in Javascript is

      myMainDoc = app.documents.itemByName(app.activeDocument.name);

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences  = NothingEnum.nothing;

      app.findGrepPreferences.findWhat = '(X_S[0-9]{5,}):'  //$1

                                                              + '([A-Z0-9]{3,})'    //$2

                                                              + '(Y_P[0-9]{5,})'    //$3

      app.changeGrepPreferences.changeTo = '$1:$3-$2';

      var myResults = myMainDoc.changeGrep();

       

      The results = 0

      That is: with this grep defined in script (and results =0) I change to InDesign and see the grep-definition in the UI, start it and get the results = 2 ! (see above)

      I read about the notes being managed by the program itself. But why does it not work in the script? (It does not matter what the notes' content is.)

      I allready changed my data to fixed length, but this did not make things better.

       

      Thank You for help in advance or be welcome to the funeral of this concept

      Dietmar