The START 7 NEXT Structure

The syntax for this structure is

«start finish START loop-clause NEXT »

START … NEXT executes the loop-clause sequence of commands one time for each number in the range start to finish. 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

 

 

counter = counter + 1

 

NEXT

 

 

 

Is

yes

 

counter finish?

 

 

no

START 7 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 7 NEXT in a program:

Press !°%BRCH% !%START%.

Example: The following program creates a list containing 10 copies of the string "ABC":

«1 10 START "ABC" NEXT 10 →LIST »

1-18 RPL Programming