1 Reply Latest reply on May 8, 2008 12:39 PM by (Olav_Kvern)

    [JS] (CS2) How to limit scope of search

    CTC Imaging Level 1
      I need help to understand where I am going wrong! PLEASE

      I am trying to limit my search with replacement to all the textFrames selected but it's not working.

      "itsWord" is a possible wrong word that was selected stepping through words in selections (TextFrames only). The user is prompted to replace it with...

      "itsTFS" is/are TextFrames selected by user.

      *** At the Document Level --> OK (They ALL change)
      var itsTXTS = app.activeDocument.search(itsWord.contents, true, true, myAnswer + mySpecialCHR);

      ***At the Text Frame Level --> Error: itsTFS.search is not a function
      var itsTXTS = itsTFS.search(itsWord.contents, true, true, myAnswer + mySpecialCHR);

      *** Stepping through --> Works SO...SO
      I can step through itsTFS but it seems that the replacement is NOT immediate.Stepping through the selections seems to repeat the same previous replacement in the following selection (TextFrame)? When the words should have already been ALL changed in ALL selection by the 1st replacement instance. It does not make sense!

      var itsTXTS = new Array;
      for (var cptTFS = 0; cptTFS < itsTFS.length; cptTFS++)
      {
      var tmp = itsTFS[cptTFS].search(itsWord.contents, true, true, myAnswer + mySpecialCHR);
      for (var cpt = 0; cpt < tmp.length; cpt++)
      itsTXTS.push(tmp[cpt]);
      }