The START 7 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

1:Start

 

finish

2:finish

 

START

counter=start

 

Store finish

 

 

 

loop-clause

Body of loop

 

increment

1:increment

 

 

counter = counter +

 

 

increment

 

STEP

 

 

 

Is

yes

 

counter finish?

 

 

 

no

 

START 7 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 7 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 » »

RPL Programming 1-19