HP 50g User's Reference Manual
Download Advanced user's reference manual of HP 48gII Calculator for Free or View it Online on All-Guides.com.
Brand: HP
Category: Calculator
Type: Advanced user's reference manual
Model: HP 48gII , HP 49g+ , HP 50G
Pages: 693
1-2 RPL Programming
x
2
y
2
+
Examples of Program Actions
Program Results
« 1 2 » 2: 1
1: 2
« "Hello" { A B } » 2: "Hello"
1: { A B }
« '1+2' » 1: '1+2'
« '1+2' →NUM » 1: 3
« « 1 2 + » » 1: « 1 2 + »
« « 1 2 + » EVAL » 1: 3
Programs can also contain structures. A structure is a program segment with a defined organization. Two basic kinds
of structure are available:
Local variable structure. The
→
command defines local variable names and a corresponding algebraic or
program object that’s evaluated using those variables.
Branching structures. Structure words (like DO…UNTIL…END) define conditional or loop structures to
control the order of execution within a program.
A local variable structure has one of the following organizations inside a program:
« →
name
1
… name
n
'algebraic '
»
« →
name
1
… name
n
«
program
» »
The → command removes n objects from the stack and stores them in the named local variables. The algebraic or
program object in the structure is automatically evaluated because it’s an element of the structure — even though
algebraic and program objects are put on the stack in other situations. Each time a local variable name appears in
the algebraic or program object, the variable’s contents are substituted.
So the following program takes two numbers from the stack and returns a numeric result:
« → a b 'ABS(a-b)' »
Calculations in a Program
Many calculations in programs take data from the stack. Two typical ways to manipulate stack data are:
Stack commands.
Operate directly on the objects on the stack.
Local variable structures.
Store the stack objects in temporary local variables, then use the variable names to
represent the data in the following algebraic or program object.
Numeric calculations provide convenient examples of these methods. The following programs use two numbers
from the stack to calculate the hypotenuse of a right triangle using the formula .
« SQ SWAP SQ + ƒ »
« → x y « x SQ y SQ + ƒ » »
« → x y 'ƒ(x^2+y^2)' »
The first program uses stack commands to manipulate the numbers on the stack — the calculation uses stack
syntax. The second program uses a local variable structure to store and retrieve the numbers — the calculation uses
stack syntax. The third program also uses a local variable structure — the calculation uses algebraic syntax. Note
that the underlying formula is most apparent in the third program. This third method is often the easiest to write,
read, and debug.