User`s guide
Looping Structures
In many cases, you will want the program to execute a block of code more than once. V+ has
three looping structures that allow you to execute blocks of code a variable number of times.
The three instructions are:
l FOR
l DO...UNTIL
l WHILE...DO
FOR
A FOR instruction creates an execution loop that will execute a given block of code a specified
number of times. The basic form of a FOR loop is:
FOR index = start_val TO end_val STEP incr
.
code block
.
END
index is a real variable that keeps track of the number of times the FOR loop has
been executed. This variable is available for use within the loop.
start_val is a real expression for the starting value of the index.
end_val is a real expression for the ending value of the index. Execution of the
loop terminates when index reaches this value.
incr is a real expression indicating the amount index is to be incremented
after each execution of the loop. The default value is 1.
Examples
88 .
89 ; Output even elements of array "$names" (up to index 32)
90
91 FOR i = 2 TO 32 STEP 2
92 TYPE $names[i]
93 END
94 .
.
102 .
103 ; Output the values of the 2 dimensional array "values" in
104 ; column and row form (10 rows by 10 columns)
105 .
106 FOR i = 1 TO 10
107 FOR j = 1 to 10
108 TYPE values[i,j], /S
109 END
Looping Structures
V+Language User's Guide, v17.0
Page 132










