The START STEP Structure

The syntax for this structure is

«start finish START loopclause increment STEP »

START … STEP executes the loopclause sequence just like START … NEXT does — except that the program specifies the increment value for the counter, rather than incrementing by 1. The loopclause is alway s executed at least once.

Syntax

Start

finish

START

loop-clause

increment

STEP

Flowchart

1:Start

2:finish

counter=start Store finish

Body of loop

1:increment

counter = counter + increment

Isyes

counter finish?

no

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 loopclause is executed. STE P 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 » »

RPL Programming 119

Page 43
Image 43
HP 48gII Graphing Start Step Structure, « … start finish Start loopclause increment Step … », Press ! %BRCH% … %START%