The Do Construct, - HP F2226A - 48GII Graphic Calculator User Manual

Graphing calculator
Table of Contents

Advertisement

Check out that the program call 0.5 ` 2.5 ` 0.5 ` @GLIS2
produces the list {0.5 1. 1.5 2. 2.5}.
To see step-by-step operation use the program DBUG for a short list, for
example:
J1 # 1.5 # 0.5 `
['] @GLIS2 `
„°LL @) @ RUN@ @@DBG@
Use @SST↓@ to step into the program and see the detailed operation of each
command.
The DO construct
The general structure of this command is:
DO program_statements UNTIL logical_statement END
The DO command starts an indefinite loop executing the program_statements
until the logical_statement returns FALSE (0). The logical_statement must
contain the value of an index whose value is changed in the
program_statements.
Example 1 - This program produces a counter in the upper left corner of the
screen that adds 1 in an indefinite loop until a keystroke (press any key) stops
0 DO DUP 1 DISP 1 + UNTIL KEY END DROP »
the counter:
«
Command KEY evaluates to TRUE when a keystroke occurs.
Example 2 – calculate the summation S using a DO...UNTIL...END construct
The following program calculates the summation
Using a DO...UNTIL...END loop:
0. → n S
DO n SQ S + 'S' STO n 1 – 'n' STO UNTIL
«
«
'n<0' END S "S" →TAG » »
Enter parameters 1 1.5 0.5
Enter the program name in level 1
Start the debugger.
n
2
S
=
k
k
=
0
Page 21-61

Advertisement

Table of Contents
loading

This manual is also suitable for:

48gii

Table of Contents