The START 7 STEP Structure
The syntax for this structure is
«… start finish START
START … STEP executes the
Syntax | Flowchart |
|
Start | 1:Start |
|
finish | 2:finish |
|
START | counter=start |
|
Store finish |
| |
|
| |
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
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
RPL Programming