Reference Guide
RPL Programming 1-19
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.
Syntax Flowchart
Start
finish
START
loop-clause
STEP
1:Start
2:finish
counter=start
Store finish
Body of loop
counter = counter +
increment
Is
counter ≤ finish?
yes
no
1:increment
increment
START STEP Structure
START takes two numbers (start and finish) from the stack and stores them as the starting and ending values of the
loop counter. Then the loop-clause is executed. STEP takes the increment value from the stack and increments the
counter by that value. If the argument of STEP is an algebraic or a name, it’s automatically evaluated to a number.
The increment value can be positive or negative. If it’s positive, the loop is executed again if the counter is less than
or equal to finish. If the increment value is negative, the loop is executed if the counter is greater than or equal to
finish. Otherwise, execution resumes following STEP. In the previous flowchart, the increment value is positive.
To enter START STEP in a program:
Press
!°
%BRCH%
…
%START%
.
Example:
The following program takes a number x from the stack and calculates the square of that number several
times (x/3 times):
«
DUP → x « x 1 START x SQ -3 STEP »
»