3.3.2.36 Loop

A simple increment loop structure.

Syntax:

loop  (variable, start, end) sentence

or

loop (variable, start, end) (script)

Initializes variable with a value of start. It then compares variable with end. If it is greater, it ends the loop. Otherwise it executes script, then increments variable by one and tests if it is greater than end. If it is not, execute script and continue to loop. This is the equivalent of one of the most common for loops:

for (Variable = Start; Variable < End; Variable = Variable + 1) {script}

Single statement script arguments end with a semicolon. Multiple statement script arguments should be enclosed in braces {}. Each statement within the multiple statement script should end with a semicolon.


Note

If your script loops endlessly, you can interrupt the script by pressing ESC.

Examples:

Example 1

The following script:

loop (num, 1, 4)  {type "$(num)";};

Produces the following output to the Script window.

1

2

3

4

Example 2

The next script prints the values of row index 20-35 in column 2 of the NewData worksheet in the form "Row 20 value is 547".

loop (num, 20, 35) 
      {
            data = %(NewData, 2, $(num));
            type "Row $(num) value is $(data)";
      }

See Also:

Break (command), Continue (command), For (command), Repeat (command), Document (command),


Exit (command), File(command), Switch (command)