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

Adobe Reader 9.0 not able to use global arrays

ADB
Registered: Nov 28 2011
Posts: 20

I have following code developed using Acrobat Pro 10.1.1
 
var arrLevelOptions_Left = new Array();
arrLevelOptions_Left[0] = "Left";
arrLevelOptions_Left[1] = "Right";
 
function SetSideValues()
{
var cmbSide = this.getField("SideDropDown");
cmbSide.clearItems();
var SideOptions11 = new Array();
arrSideOptions11[0] = "Left";
arrSideOptions11[1] = "Right";
cmbSide.setItems(arrSideOptions11); //Code Works fine till this point.
//cmbSide.setItems(arrLevelOptions_Left);//This gives Error.
app.alert(arrLevelOptions_Left);// Shows "undefined"
}
  
I can run this code without error in Acrobat X Pro 10.1.1 but when I try to open this PDF in Reader 9.0 following error is thrown,
 
arrLevelOptions_Left has no properties
206:AcroForm:SideDropDown:KeystrokeException in line 206 of function SetLevelValues, script Document-Level:MainScript
Line: 70: Code: -36(0xffdc): Not implemented
Line: 70: Code: -36(0xffdc): Not implemented
 
The line number mentioned in the error message belongs to the line commented out in above code.
 
What I can not grasp is how come the function is able to access only the array defined inside the function and not the global array. Can anyone please throw some light on this issue? Thanks in advance.

My Product Information:
Reader 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
This along with information form you other post leads me to believe that there's a problem with your Reader 9 installation. I've seen this type of thing happen before and suggest that you first try a repair, and if that doesn't work, uninstall and reinstall. Do you have a good reason for not using the latest update for Reader 9?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
I do not see a 'global' object defined. It appears you mean document variable defined by a document level script.

A variable defined or even redefined within a function only exist as long as the function is running. when the function ends all variables defined within the function cease to exist.

You might want to check the names you are using for accessing and setting the array values.

Also you should consider assigning values to an array when you declare the array:

var arrLevelOptions_Left = new Array(""Left", "Right");

var SideOptions11 = new Array("Left", "Right");

JavaScript is an interruptive language and stops upon any syntax error or run error.

George Kaiser

ADB
Registered: Nov 28 2011
Posts: 20
gkaiseril wrote:
Also you should consider assigning values to an array when you declare the array:

var arrLevelOptions_Left = new Array(""Left", "Right");

var SideOptions11 = new Array("Left", "Right");


First of all thanks for pointing out that those are document variables and not global. I tried all the things that you have mentioned still no luck.
ADB
Registered: Nov 28 2011
Posts: 20
Hi George, according to your advice I uninstalled Reader 9.0 and installed fresh version of Reader 9.4 I need this to work with Reader 9.x so I havent installed Reader X. When I open the my file now, I get following errors on the console.

This is the error I get when I try to add a link programmatically to the page.

l = addLink(p, [Number(r1[4]) - 2, r1[5], Number(r2[2]) + 2, r2[3]]);

NotAllowedError: Security settings prevent access to this property or method.
Doc.addLink:131:Document-Level:MainScript

The link still gets added and works properly?????

In the code I have set up the keystroke event to populate another combo-box. Thats where I get the following error. I have pasted my code here ,


var arrSideOptions = new Array(); //Also tried var arrSideOptions = new Array("Left","Right");
arrSideOptions[0]="Left";
arrSideOptions[1]="Right";

SetSideValues();

function SetSideValues()
{
var cmbSide = this.getField("SideDropDown");
cmbSide.clearItems();
var arrSideOptions11 = new Array();
arrSideOptions11[0] = "Left";
arrSideOptions11[1] = "Right";
cmbSide.setItems(arrSideOptions11); //First combo-box gets populated properly.
//cmbSide.setItems(arrSideOptions); //Throws error
}



//On the KeyStroke event of "SideDropDown" I have set up the following function to be called with "event.value".

function SetLevelValues()
{
var cmbLevel = this.getField("LevelDropDown");
cmbLevel.clearItems();
if (event.value == arrSideOptions[0]) //This is the line where the below mentioned errors are thrown.
{
cmbLevel.setItems(arrLevelOptions_Left);
}
else if (event.value == arrSideOptions[1])
{
cmbLevel.setItems(arrLevelOptions_Right);
};
}



arrSideOptions is undefined
226:Field:Keystroke
TypeError: arrSideOptions is undefined
226:Field:Keystroke
arrSideOptions is undefined
226:Field:Keystroke
TypeError: arrSideOptions is undefined
226:Field:Keystroke


I hope this code helps you get better understanding of what is happening