User Tools

Site Tools


4rpl:commands:do

This is an old revision of the document!


Index

do

do(<-limit <-start)

Description

The statements following the do, up to the loop statement, are executed repeatedly. An index counter is initialized to (start). The index will be incremented, or decremented, by one at the bottom of the loop. When the index counter is one away from the limit, execution will proceed at the first statement following Loop. Loops can be nested, but no more than 3 deep.

NOTE: If (limit) is less than (start), the the loop decrements rather than incrementing. The range of a do loop is always (start,limit] (inclusive of start and exclusive of limit).

Examples

# single loop
do(3 0)
   trace(I)
loop
#  Prints:
#  0
#  1
#  2
 
# single decrementing loop
do(0 3)
   trace(I)
loop
#  Prints:
#  3
#  2
#  1
 
Nested loops
 
do(2 0)
    trace(I)
    Do (4 2)
        Trace2 (J I)
        Do (6 4)
            Trace3 (K J I )
        loop
    loop
loop

Index

4rpl/commands/do.1637273629.txt.gz · Last modified: 2021/11/18 17:13 by Karsten75