CERN home page CERN home page Consult pages Consult pages Writeups at CERN Writeups at CERN Garfield pages Garfield pages Help Help This page This page Table of contents Keyword index

Do_loop


For

If you use the For keyword in the header line of a Do loop, then you request a loop variables (var) to be incremented at each iteration of the loop. Hence you have to specify the name of the variable, its initial value, the final value and optionally also the increment.

var

The name of the global variable to be incremented at each iteration. It does not have to be declared before the loop.

The value is automatically set at the start of each pass through the loop. You may change the value of this variable inside the loop.

The name of the variable should obey the naming conventions for global variables.

This variable is of type Number.


from

The initial value of the loop variable.

This parameter must be a global variable of type Number or an expression that evaluates to a Number.

[This argument is mandatory if the loop has a loop variable associated with it. No default is provided.]


step

The increment of the loop variable. The increment may assume positive and negative values. Also 0 is permitted.

This expression is evaluated anew at each iteration.

This parameter must be a global variable of type Number or an expression that evaluates to a Number.

[If no step size is indicated, a default value of 1 is assumed.]


to

For positive increments, the loop is left as soon as the loop variable exceeds this value. For negative increments, the loop is left as soon as the variable is less than to.

This expression is evaluated anew each iteration.

This parameter must be a global variable of type Number or an expression that evaluates to a Number.

[This argument is mandatory if the loop has a loop variable associated with it. No default is provided.]


while

The while condition is evaluated after the loop variable, if used, has been incremented and before a new iteration begins. You have to ensure that while is assigned a value before you execute the loop. Iteration is left as soon as the condition fails to hold.

This expression is evaluated anew each iteration.

This parameter must be a global variable of type Logical or an expression that evaluates to a Logical.

[This optional parameter is by default set to True.]


until

The until condition is evaluated at the end of each iteration and does not need to have a value before the Do loop. The loop variable is incremented for the next cycle before until is calculated. Iteration is left as soon as the condition holds.

This parameter must be a global variable of type Logical or an expression that evaluates to a Logical.

[This optional parameter is by default set to False.]


Leave

Causes iteration to stop, no matter the While, Until and To conditions.

You may specify as an argument the name of the loop variable associated with the loop you wish to leave.


Iterate

Causes the remaining part of this pass through the loop to be skipped. Execution resumes at the top of the loop.

You may specify as an argument the name of the loop variable associated with the loop you wish to leave.


Go to the top level, to Do_loop, to the topic index or to the table of contents.

Formatted on 0100-08-24 at 22:38.