7 Replies Latest reply on Apr 11, 2017 7:40 AM by Karl Heinz Kremer

    Find specific words within an array of words

    Jo_2013 Level 1

      Following script will report all words on the page to the console with a space between each word

       

      var i, j, ckWord, numWords, aWords = [];

      for (i = 0; i < this.numPages; i++ ) {

      numWords = this.getPageNumWords(i); for (j = 0; j < numWords; j++) {

      ckWord = this.getPageNthWord(i, j)

      if (ckWord) {

      aWords.push(ckWord);  // Add word to array

      }

      }

      var m = aWords.join(" ");

      console.println("Words found are " + m);

      }

       

      The following script is a variation of the above script to find words within the array of words reported to the console.

      It is not working though, the number 730 is reported back to the console not the searched for words an example being  "SERVICES PLAN SHEET" .

       

      Can anyone please provide assistance to modify the script to find words within an array of words.

       

      var i, j, ckWord, numWords, aWords = [];

      for (i = 0; i < this.numPages; i++ ) {

      numWords = this.getPageNumWords(i); for (j = 0; j < numWords; j++) {

      ckWord = this.getPageNthWord(i, j)

      if (ckWord) {

      aWords.push(ckWord);  // Add word to array

      }

      }

      var m = aWords.join(" ");

      if (m == "SERVICES PLAN SHEET")

      {

      console.println(m);

      }

      }

       

      730 (this is what is reported to the console)

       

      Many thanks.