1-18 RPL Programming
Syntax Flowchart
Start
finish
START
loop-clause
NEXT
1:Start
2:finish
counter=start
Store finish
Body of loop
counter = counter + 1
Is
counter ≤ finish?
yes
no
START … NEXT Structure
START takes two numbers (start and finish) from the stack and stores them as the starting and ending values for
a loop counter. Then, the loop-clause is executed. NEXT increments the counter by 1 and tests to see if its value
is less than or equal to finish. If so, the loop-clause is executed again — otherwise, execution resumes following
NEXT.
To enter START … NEXT in a program:
! Press !°%BRCH% !%START%.
Example: The following program creates a list containing 10 copies of the string "ABC":
! "!3!38!D:BK:!IBSOI!=<T:!38!#E6D:!1!
The START … STEP Structure
The syntax for this structure is
! «!…!start finish!START!loop-clause increment!STEP!…!»
START … STEP executes the loop-clause sequence just like START … NEXT does — except that the program
specifies the increment value for the counter, rather than incrementing by 1. The loop-clause is always executed
at least once.