EasyManua.ls Logo

HP 48GII

HP 48GII
653 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
RPL Programming 1-21
Syntax Flowchart
Start
finish
FOR
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
FOR … STEP Structure
FOR takes start and finish from the stack as the beginning and ending values for the loop counter, then creates
the local variable counter as a loop counter. Next, the loop-clause is executed — counter can appear within the
loop-clause. STEP takes the increment value from the stack and increments 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 the increment is positive, the loop is executed again if
counter is less than or equal to finish. If the increment is negative, the loop is executed if counter is greater than
or equal to finish. Otherwise, counter is purged and execution resumes following STEP. In the previous
flowchart, the increment value is positive.
To enter FOR … STEP in a program:
! Press %BRCH% %FOR%.
Example: The following program places the squares of the integers 1, 3, 5, 7, and 9 on the stack:
! «!3!X!7LK!?!?!DU!H!D:<2!1!
Example: The following program takes n from the stack, and returns the series of numbers 1, 2, 4, 8, 16, …,
n. If n isn't in the series, the program stops at the last value less than n.
«!3!DYB2!7LK!G!G!G!D:<2!1!
The first n is the local variable declaration for the FOR loop. The second n is put on the stack each iteration of
the loop. The third n is used by STEP as the step increment.
Using Indefinite Loop Structures
The DO … UNTIL … END Structure
The syntax for this structure is

Table of Contents

Other manuals for HP 48GII

Related product manuals