Do 

Do


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 either

You may change the value of this variable inside the loop. If you do so in a "From-Step-To" loop, then the increment for the next iteration will be added to the modified value. Such a modification has no effect on the next iteration in a "In" loop, nor does it affect the contents of the matrix from which the values are taken.

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.

"From-Step-Do" loops should not have an In clause.

[This argument is mandatory for "From-Step-To" loops. No default is provided.]


step

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

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

This expression is evaluated anew at each iteration.

"From-Step-Do" loops should not have an In clause.

[This argument is permitted only in "From-Step-To" loops. 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 parameter must be a Global variable of type Number or an expression that evaluates to a Number.

This expression is evaluated anew each iteration.

"From-Step-Do" loops should not have an In clause.

[This argument is mandatory for "From-Step-To" loops. No default is provided.]


in

Should be an expression that evaluates to a Matrix. This matrix is allowed to have any number of dimensions. The loop variable will assume each of the values found in the matrix, unless the loop is terminated via While, Until or Leave.

This expression is evaluated anew at each iteration. It is permissible to modify the matrix in the body of the loop.

From, Step and To must not be used in "In" loops, but you may use While and Until.

[This argument is mandatory for "In" loops. There is no default matrix.]


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 parameter must be a Global variable of type Logical or an expression that evaluates to a Logical.

This expression is evaluated anew each iteration.

[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, "break" may be used instead of "Leave" if preferred.

[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, "continue" may be used instead of "Iterate" if preferred.

[Use of an Iterate statement is optional.]


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

Formatted on 21/01/18 at 16:55.