HP (Hewlett-Packard) HP 33s Calculator User Manual


 
12–12 Simple Programming
File name 33s-English-Manual-040130-Publication(Edition 2).doc Page : 388
Printed Date : 2004/1/30 Size : 13.7 x 21.2 cm
Press
¥
(run/stop) to resume the program. The value you keyed in then writes
over the contents of the X–register
and is stored in the given variable. If you have
not changed the displayed value, then that value is retained in the X–register.
The area–of–a–circle program with an INPUT instruction looks like this:
RPN mode ALG mode








π














π




To use the INPUT function in a program:
1. Decide which data values you will need, and assign them names.
(In the area–of–a–circle example, the only input needed is the radius, which
we can assign to
R.)
2.
In the beginning of the program, insert an INPUT instruction for each variable
whose value you will need. Later in the program, when you write the part of the
calculation that needs a given value, insert a
h
variable instruction to bring
that value back into the stack.
Since the INPUT instruction also leaves the value you just entered in the
X–register, you don't
have to recall the variable at a later time — you could
INPUT it and use it when you need it. You might be able to save some memory
space this way. However, in a long program it is simpler to just input all your
data up front, and then recall individual variables as you need them.
Remember also that the user of the program can do calculations while the
program is stopped, waiting for input. This can alter the contents of the stack,
which might affect the next calculation to be done by the program. Thus the
program should not assume that the X–, Y–, and Z–registers' contents will be
the same before and after the INPUT instruction. If you collect all the data in
the beginning and then recall them when needed for calculation, then this
prevents the stack's contents from being altered just before a calculation.