These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

break the for loop

ranjaxt2012
Registered: Sep 2 2010
Posts: 3

it is printing continous chain of three words ending with word null.
 
i tried in may ways but it is not helping. what i want my program to do is, if it finds the third word followed by first and second word then print it and end the loop.
  
var myplane, chWord, chWord2, chWord3, numWords;
 
for (var i = 0; i < this.numPages; i++)
{
numWords = this.getPageNumWords(i);
 
for (var j = 0; j < numWords; j++)
{
chWord = this.getPageNthWord(i,j);
chWord2 = this.getPageNthWord(i,j+1);
chWord3 = this.getPageNthWord(i,j+2);
 
if (chWord == "Applicability")
{
if (chWord2 == "Effectivity")
{
myplane = chWord3;
console.println(myplane);
break;
}
}

}
}

Anup Singh

try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can use labels, like so:
outerloop:for (var i = 0; i < this.numPages; i++){numWords = this.getPageNumWords(i); innerloop:for (var j = 0; j < numWords; j++){chWord = this.getPageNthWord(i,j);chWord2 = this.getPageNthWord(i,j+1);chWord3 = this.getPageNthWord(i,j+2); if (chWord == "Applicability"){if (chWord2 == "Effectivity"){myplane = chWord3;console.println(myplane);break outerloop;}} }}
Also, you need to adjust the inner loop so that it only runs to the maximum number of words in a page minus 2.
Otherwise, if the words you're looking for are not found, there will be an exception when you try to get words which are higher than the amount of words on that page.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
You might not jump every three words but check every word and the next two words from that word.

George Kaiser