Download  Print this page

HP -28S Manual Page 243

Advanced scientific calculator.
Hide thumbs

Advertisement

Techniques:
• Local-variable structure. Local variables allow you to assign names
to arguments without conflicting with global variables. Like global
variables, local variables are convenient because you can use argu-
ments any number of times without tracking their positions on the
stack; unlike global variables, local variables disappear when the
program structure that creates them is done.
A local-variable structure has three parts.
1. A command named ".;. ". When you key in this command, re-
member to put spaces before and after it. (Like any command,
.;. is spelled using normal characters and is recognized only
when it's set off by spaces. Don't confuse this one-character
command with delimiters like
#
or ·s:.)
2. One or more names.
3. A procedure (expression, equation, or program) that includes
the names. This procedure is called the
defining
procedure.
When a local-variable structure is evaluated, a local variable is cre-
ated for each name. The values for the local variables are taken
from the stack. The defining procedure is then evaluated, substitut-
ing the values of the local variables.
To appreciate the power of local variables, compare the version of
BOXS given below with the version that appears on page 244 .
• User function. This type of program works in either RPN or alge-
braic syntax. A user function is a program that consists solely of a
local-variable structure and returns exactly one result.
Program
.;. h ... )
Comments
Begin the program.
Create local variables for height,
width, and length. By conven-
tion, lower-case letters are used.
The values are taken from the
stack (in RPN) or from the argu-
ments to the user function (in
algebraic syntax).
242
28: Programming Examples

Advertisement

Table of Contents

   Also See for HP HP-28S

   Related Manuals for HP HP-28S

Comments to this Manuals

Symbols: 0
Latest comments: