Using Loop Structures; Using Definite Loop Structures - HP 48gII Advanced User's Reference Manual

Graphing calculator
Hide thumbs Also See for 48gII:
Table of Contents

Advertisement

Program:
«
 y
«
CASE
y TYPE 2 SAME
THEN y 'STR' STO
END
y TYPE 5 SAME
THEN y 'LIST' STO
END
y TYPE 8 SAME
THEN y 'PROG' STO
END
END
»
»

Using Loop Structures

You can use loop structures to execute a part of a program repeatedly. To specify in advance how many times to
repeat the loop, use a definite loop. To use a test to determine whether or not to repeat the loop, use an indefinite
loop.
Loop structures let a program execute a sequence of commands several times. Loop structures are built with
commands — called structure words — that work only when used in proper combination with each other. These
loop structure commands are contained in the PRG BRCH menu (!° %BRCH%):
START... NEXT and START... STEP.
!
FOR ... NEXT and FOR...STEP
!
DO ... UNTIL ...END.
!
WHILE... REPEAT... END.
!
In addition, the
function provides an alternative to definite loop structures for summations.

Using Definite Loop Structures

Each of the two definite loop structures has two variations:
NEXT. The counter increases by 1 for each loop.
!
STEP. The counter increases or decreases by a specified amount for each loop.
!
The START ... 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.
Comments:
Defines local variable y.
Starts the defining procedure.
Starts the case structure.
Case 1: If the argument is a string, stores it in STR.
Case 2: If the argument is a list, stores it in LIST.
Case 3: If the argument is a program, stores it in
PROG.
Ends the case structure.
Ends the defining procedure.
RPL Programming 1-17

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

49g+

Table of Contents