HP49G / HP49G+ Tutorials

Part 3 - Basic Programming

 

Other Tutorials Here

 

 

The HP4x series of calculators have an easy way to program, known as 'User RPL' uRPL is like a basic scripting language. Most users use it to automate repetitive tasks. It can do far more advanced thing but that is beyond the scope of this page.

 NOTE: To see any programs or other objects stored in your calculator's current directory, press the VAR key ('Show VARiables').

 

Using uRPL to create macro's is extremely simple.

  1. Enter the program delimiters (<< and >>) to tell the calculator you are writing a program
  2. Enter the keystrokes you would enter manually to calculate something
  3. Press ENTER, type the name of your program, and Press STO.

 

Example: Create a program to square the Top of the Stack.

 

Why do this you ask - there's already an x^2 key! Yes, but you have to press shift each time you use it - it's a bit annoying. Here's how to create a program that only requires one keystroke, not two.

To square an object, we would normally enter '2' then 'y^x'.

Press Right-Shift Plus to enter the program delimiters - notice the PRG in the top right corner?

Press 2

Press y^x

Press ENTER - the program is sitting on the stack

Type the name of the program - we'll call it SQU

Press STO. Notice 'SQU' appears in the softmenu on the lower left? (You may need to press 'VAR')

 

The program has been finished - but we need to test it.

 

Type 5

and press the softkey under SQU. 5 is squared to get 25.

Press SQU again to square 25 (and get 625 as expected)

 

Example: Create a program to calculate the equivilent resistance of 2 resistors in parallel.

 

This program will take 2 values from the stack, invert them both, add them and invert the result. This is a little trickier, as we need to use the Stack Manipulation Commands (You'll see why soon).

If we did it by hand, here's the process we'd have to do.

 Suppose the user has already entered 6 and 7 ohms for the resistor vales

Press 1/x to invert the first value

Use 'SWAP' to swap the 2 values

invert the second value

Press + to add them

Invert the result.

 

The program looks like

There are 2 ways to get the SWAP. You can either Press Tools, then Stack, then select Swap, OR just type it by hand. Note that SWAP is so handy that you can normally press the right arrow key to SWAP - but this shortcut only works at the stack, and not while programming.

 

 And here it is, stored into RPAR (Resistors in PARallel).

 

Lets test it with the problem given in the first RPN example - 5,6,7 ohm resistors in parallel.

 

Type 5, ENTER, then 6 (You don't need to hit ENTER again)

Press the RPAR SoftKey to get the equiv resistance of 5 and 6 ohm resistors

Press 7

Press RPAR to parallel the result with a 7ohm resistor.

 

Again, you can press ->Num to obtain an inexact numeric answer. You can make this part of the program if you want, but it obscures the working.

 

 

 See The Other Tutorials Here