FORV |
"For" is used to make variable assignment loops.
For file read loops, refer to the instruction documentation marked For(file)).
SYNTAX 1For variable_num = value_init To value_end [ Step step ]
..... instructionsNext [ variable_num ]SYNTAX 2For variable = list_values
..... instructionsNext [ variable ]
|
Element |
Description |
Restrictions |
|
variable_num |
numerical type nom_de_variable containing the value of the loop, which changes from 'value_init' by 'step' increments. |
None. |
|
value_init |
Initial numerical value of the variable. |
None. |
|
value_end |
Final numerical value of the variable. |
None. |
|
step |
Increment added to the variable with each iteration (1 by default). |
None. |
|
variable |
nom_de_variable whose value will take each of the values of the list in succession. |
None. |
|
list_values |
List of expressions separated by the character ','. |
The expressions are the same type as the variable. |
For I = 1 To 13 Step 2.5 : Infbox num$(I) : Next I : Infbox "FIN="-num$(I)
# displays : 1 3.5 6 8.5 11 FIN=13.5For I = 15 To 12 : Infbox num$(I) : Next I : Infbox "FIN="-num$(I)
# displays : FIN=15For I = 15 To 11 Step -1 : Infbox I : Next I : Infbox "FIN="-num$(I)
# displays : 15 14 13 12 11 FIN=10For CHN="A","EF","X","ZZZ" : Infbox CHN : Next CHN : Infbox "FIN="-CHN
# displays: A EF X ZZZ FIN=ZZZ
SYNTAXES 1 AND 2
"For" is used to make loops in which a variable takes a set of values. The value of the variable must not be modified within the loop.
The only ways of leaving a For loop are:
· to reach the limits (syntax 1),
· to have exhausted all values (syntax 2),
· to use Break, interrupting the loop.
Value of the loop variable on leaving the loop:
· the first value outside the limits (syntax 1),
· the last value on the list (syntax 2).
Number of iterations:
If (value_end - value_init) does not have the same sign as the step, the loop will never be executed, and the value on leaving the loop will be the initial value.
In syntax 1, the loop variable, its initial and final values and the step are not reevaluated in the loop.
|
Error |
Description |
|
ERMODE (10) : |
- variable_num,
value_init, value_end, or the step are not numerical (syntax 1). |
|
ERLOOP (41) |
The step value is null. |
|
|