Avatar

Correct answer by
Level 10

Hi,

This works because the script within the parentheses {} is re-run until the value of i matches 25.

The loop is constructed in three parts:

var i=1;     This declares the variable i and sets it with an initial value of 1

i <=25;     This is a test, the loop runs until i is greater than 25

i++           This increases the value of i by 1 each time the loop is run

When you put is all together as...

for (var i=1; i<=25; i++)

{

     // script in here will run 25 times

}

If you are using a hidden field for the number of pages, you would set this with a default value at design time (Object > Value palette). Then the for statement would look like this:

for (var i=1; i<=totalNumberPages.rawValue; i++)

You do not need to alter the i variable at all.

Hope that helps,

Niall

Assure Dynamics

View solution in original post