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

embeded trusted functions in a function (embeded functions)

ranjaxt2012
Registered: Sep 2 2010
Posts: 3

I know it is the issue of using doc object, but i am so confused about how.
 
This function is not executing, it stops at "this.getPageNthWords" because "this.xxxxx" is not at document level object, but how can it make is work, please help.
  
var myAirplanefunc = app.trustedFunction(function()
 
{
app.beginPriv();
var apWord, apWord2, apnumWords;
 
var myactivedoc = app.activeDocs;
 
apnumWords = myactivedoc.getPageNumWords(1);
// also tryed
// apnumWords = this.getPageNumWords(1);
 
for (var z = 0; z < apnumWords; z++)
{
apWord = this.getPageNthWord(1,z);
 
apWord2 = this.getPageNthWord(1,z+1);
  
if (apWord == "Model")
{
 
if (apWord2 == "xxx" || apWord2 == "xxw")
{
var myairplane = apWord2;
app.alert("The airplane is " + myairplane)
}
 
}
 
}
app.endPriv();
 
});
  
var myapeff = app.trustedFunction(function()
 
{
app.beginPriv();
var myeff, effWord, effWord2, effWord3, effnumWords;
 
for (var i = 0; i < this.numPages; i++)
{
effnumWords = this.getPageNumWords(i);
 
for (var j = 0; j < effnumWords; j++)
{
effWord = this.getPageNthWord(i,j);
effWord2 = this.getPageNthWord(i,j+1);
effWord3 = this.getPageNthWord(i,j+2);
 
if (effWord == "Applicability")
{
if (effWord2 == "Effectivity")
{
myeff = effWord3;
app.alert("Your Effectivity is :- " + myeff);
}
}

}
}
app.endPriv();
});
var myAirplanefunctest = app.trustedFunction(function()
{
myAirplanefunc();
myapeff();
});
 
// Add Menu Item
app.addMenuItem({cName:"AMM Linker",cParent:"Tools",cExec:"myAirplanefunctest()"});
  

Anup Singh

My Product Information:
Acrobat Pro 9.1.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You have to pass a reference to the document object to the function as a parameter.

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

ranjaxt2012
Registered: Sep 2 2010
Posts: 3
in this case i am not passing or accepting variables. i am just looking for some words and trying to create link around it.

i guess i am not a strong programmer so i am not sure how to get it through it. please help me with this parameter issue. can you give me an example.

Anup Singh