For…Next

Implements a For…Next loop in a Math worksheet. The section of script included in the loop begins with the For() call and ends with the Next notation. The Next notation directs back to the beginning of the loop.

Function Group Execution Windows Embedded Thin Client Mobile Access
For Loop N/A Supported Supported Supported Not supported

Syntax

Web Studio Help erences2fr function loop for.xml d145058e98 For…Next
  For( numInitialValue, numFinalValue, numStep )  
numInitialValue
The initial or starting value of the loop.
numFinalValue
The final or ending value of the loop.
numStep
The step or increment value.

Returned value

This function returns the current value of the loop.

Notes

You must partner every For() call with a Next notation, although you may have any number of worksheet rows between them. And as shown in the example below, you must place the Next notation in the Tag Name column of the worksheet.

The loop ends when its current value equals the value of numFinalValue. Specifically, each time the execution of the worksheet encounters the Next notation, the following happens:
  1. The value of numStep is added to the current value of the loop;
  2. The execution returns to the For() call at the beginning of the loop; and
  3. The current value of the loop is compared to the value of numFinalValue. If the current value is less than numFinalValue, then the loop is executed again. If the current value is greater than or equal to numFinalValue, then the loop is skipped and execution resumes with the first row after the Next notation.

Please note that the For…Next loop may only be used in Math worksheets. It may not be used in either Command animations or any VBScript interface. (VBScript has its own For…Next statement.)

Examples

Table 1. Example of For…Next loop in a Math worksheet
Tag Name Expression
MyTag For(1,5,1)
tagname function
tagname function
tagname function
Next  

For…Next