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

Do_loop


var

When you use the For clause followed by the name of a variable, you request this variable to be incremented before each iteration of the loop. You must in this case specify at least an initial value and a final value. You may also specify an increment. You may change the value of this variable inside the loop.

The loop variable can be used anywhere inside the body of the loop to perform calculations. It can also be referenced in the Leave and Iterate statements.

The loop variable is a Global of type Number. It does not have to be declared before the loop. Its name should obey the naming conventions for global variables.

[This is an optional parameter.]


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.

Leave is the Garfield equivalent of the break statement in C.

[Use of a Leave statement is optional.]


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.

Iterate is the Garfield equivalent of the continue statement in C.

[Use of an Iterate statement is optional.]


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

Formatted on 15/01/01 at 23:07.