DO statement
- Last Updated: October 29, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
The DO statement groups statements into a single
block. An END statement ends the DO block.
The
DO block can be a simple non-iterating block, or you
can use it to iterate. There are two ways you can control iteration in a DO block:- Iterate a specified number of times
- Iterate while a condition is true
Iterate a specified number of times
To iterate for a specified number of times, you provide a starting and ending
integer value for the iteration. By default, the iteration value increments by 1 at the
end of each iteration. Optionally, you can provide a different increment or decrement
value using the BY clause. The iteration ends when the ending value is reached. This is
the basic syntax for using DO to iterate a specified number of
times:
|
The following is an example
|
Running the code produces the following output:
|
Iterate while a condition is true
You can also iterate while a condition is true by using the DO WHILE
construct. The following is an example:
|
Running the code produces the following output:
|