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

resolveNode problem

DanielKunz
Registered: Jan 22 2008
Posts: 55

Hi all,
I try to delete empty subform instances in my form.

code:
for(var i = 0; i

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is a classic beginner programming error. Everytime you delete an entry from the list of nodes it get's shorter, i.e. you have fewer indexes to deal with. For example, when index 0 is deleted, index 1 becomes the new index 0.

When you delete half the list, only half is left. And since your loop is counting up the next index is 1/2 the original entries + 1, which is exactly one more than exists. Resolve nodes shouldn't be returning a non-null value, but maybe something else is going on.

Change your loop to count down from the largest index. And also change to the "resolveNodes()" function, which returns a list of all the nodes that match. This is much more efficient.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script