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

accessing the dataObject in reverse order

brian3017
Registered: Jan 14 2008
Posts: 18
Answered

Hello
I'm trying to access the dataObject in reverse order - that is, I'm adding PDFs to a package and I've got a field to show the contencts of the package - this part works great. However, I want the PDF added last to be on the top of my list. This is my coded, the first part works fine, but when I try decrementing the var i, it falls over. Any thoughts would be much appreciated.
regards
brian

var d = this.dataObjects;
for (var i = 0; i < d.length; i++)
// for (var i = d.length; i > 0; i--)
console.println("Data Object [" + i +"] = "+d[i].path);

Data Object [0] = Onetel.pdf
Data Object [1] = Craft - orderNum12560.pdf

true

=======================================================
var d = this.dataObjects;
// for (var i = 0; i < d.length; i++)
for (var i = d.length; i > 0; i--)
console.println("Data Object [" + i +"] = "+d[i].path);

d[i] has no properties
4:Console:Exec
undefined

My Product Information:
Acrobat Pro 8.1.2, Windows
brian3017
Registered: Jan 14 2008
Posts: 18
I suppose it's not common for someone to answer their own problem, but here goes.

Try this:

for (var i = d.length -1; i>=0; i--)the problem is the initial value of d.length was 4 and there was no forth element in the array thus the error message

d[i] has no properties
4:Console:Exec
undefined