Introduction Getting Started Basic Calculation Advanced Calculation Scripts Script Programming

Glossary

Changes by Version

# Introduction

## What is RPN?

RPN is an advanced and highly customizable postfix calculator for scientific, engineering, and financial calculations. Please purchase RPN if you find it useful.

## Major Features

 Postfix Graphing Solving Programmable Recordable Hi-res interface Customizable colors Scientific and engineering functions Conversion functions Many format and base options Script editor No need for MathLib Palm OS 3.1 or later High precision 100k in size

## Cost and Registration

There are two levels at which to purchase RPN:
• Standard - \$29 - Free upgrades for life. Normal personal or professional use.
• Student - \$19 - Free bug fixes. Student or infrequent hobby use.

## RPN Coweb

The RPN Coweb is an online, structured discussion forum for all RPN customers to benefit from and contribute to. Click the link above to view the coweb.

Everyone can read the coweb contents. If you Join the Coweb, you can edit every page of content to help create the most adaptable and structured record of RPN information possible including uploading your own scripts.

# Getting Started

## Getting Oriented

### Postfix Calculations

The basic idea of a postfix or revese polish notation calculator is that all operations take their arguments from a stack; which means, all numbers required by an operation are entered before the operation is selected. The stack is a storage area for numbers. The last value added to the stack is called the top of the stack (tos) and is the first item available when the stack is accessed. Note: RPN shows the stack building upwards from the input line.

Rather than debate the benefits of this calculator style, I'll show a few examples. Note that operations "enter" the current input, so an 'enter' is not needed before an operation. (see the first example).

```         4+2 --> 4 enter 2 enter + --> 4 enter 2 +
(12+sin(7))/(11*3.1415) --> 7 sin 12 + 11 enter 3.1415 * /
```
Other Sources:
HP's RPN Tutorial

Unlike some postfix models (such as 4-level RPL by HP), in RPN what you see in the display always represents the top part of the stack. This model is more obvious to most people and was used in the HP-28 and HP-48 series of postfix calculators.

### Stack and Input Area

 The stack is displayed moving upwards in the upper left area of the screen. Just below the stack is the main input area (also to the left of the delete button). The input area is where you build up numerical input; when there is no numerical input the input area is used to display the first stack value.

### Script Area and Button

 The script area in the upper right corner of the display is fully customizable and dedicated to providing user input to RPN's powerful scripting language, RPN-Code. Each script controls this portion of the RPN screen to display a set of buttons which execute the RPN-Code defined for them. RPN includes a number of standard scripts to calculate trigonometric functions, logs &powers, unit conversions, etc. Users can easily create their own scripts or download scripts written by others. You can scroll through the scripts using the scrolling keys on your device or pick a script from the popup list presented by tapping the script button which pops up a list of the installed scripts. Choose one and it will become the current script which is displayed in the upper right hand corner. Note, you can also scroll through the installed scripts using the page up and down keys on the device. See Built-In Scripts for an overview of each script that comes with RPN.

### Recordings Button

RPN can record calculations you preform. Think of this feature like a 'watch and learn' way to build a calculation for later playback. Simply start the recording, perform the actions of your calculation, and then stop the recording. Recorded equations can then be played back, graphed, or solved (solving takes place inside the graphing dialog).

 Record Begins recording all calculations, overwriting the last recording. Note, if you'd like to record a function that takes one input value, then you should put a value on the stack before recording since the input is not part of the function. Stop Stop the current recording. Play Playback the current recording. Graph/Solve Graph the current recording. Note, the recording needs to take one input and produce one output. Save... Specify a name to save the current recording under (requires Palm OS 3.5 or later). Load... Choose a previously saved recording to load. Delete... Choose a saved recording to delete.

## Drag and Drop

 Dragging items around with the pen is a common shortcut to many RPN operations and in some cases the only way to use some features. To drag, tap a draggable item and, without lifting the stylus, drag that item to its destination and lift the stylus to drop. In the illustration, the blue areas are draggable items, while both the blue and red areas can be the destination of a dragging action. The most important operations are listed below (though you may discover others):
Store and recall of values
To store a value, drag the value from the stack to one of the number buttons (0-9). Later you can drag the value back out of the number button and into any visible stack position.
Perform operations on values
Drag a value (either from the stack or a storage location) and drop it onto any single argument operation (locations shown in red above).
Undo the last operation
Drag the delete button to the main input area (just to the left).
Reorganize the stack
Drag a value from one stack position to another. Hint: tapping a value will move it to the top of the stack.
Duplicate a value
Drag a value to the 'Enter' button to copy it to the top of the stack.
Delete a value
Drag the value from the stack to the 'Delete' button.

There are several ways to get to the menus in RPN. You can use the menu button (usually located in or near the Graffiti area), the menu key on devices with keyboards, or simply tap the top-left corner of the display (it's easiest to tap all the way in the corner at the edge of the screen itself).

 Drop All Clear the stack. Last Stack Return the stack to previous state. Shortcut: Drag 'Delete' button to input area. Drop ( x --> ) Delete the top stack item. Shortcut: Drag value to 'del' button. Swap ( x y --> y x ) Move the 2nd stack item to the top. Shortcut: Tap the second stack item. Dup ( x --> x x ) Duplicate the top stack item. Shortcut: Tap the top stack item. Over ( x y --> x y x ) Copy the 2nd item to the top of the stack. Shortcut: Drag value to 'Enter' button. Rot ( x y z --> y z x ) Move the 3rd stack item to the top. Shortcut: Drag value to top of stack (input area).

 New... Open the script editor and start a new script. Edit... Open the script editor and load the RPN-Code for the current script. If you change the title of the script in the RPN-Code that changes which script you are editing. Note: If you defined the script in a previous version of RPN you will need to reinstall your source either by simply pasting your source into the script editor. Delete... Delete the current script. Move(Front) Move the current script to the beginning of the list of scripts. Move(Back) Move the current script to the end of the list of scripts. Move(X) Make the current script Xth in the list of scripts where X is the number on the stack. Reinstall All... Reinstall the default scripts; you will be asked to confirm any replacement of current scripts. Key Shortcuts... Define shortcut keys for common buttons using the "Key Shortcuts" dialog. All input mechanisms are treated the same so you can define Graffiti and keyboard based shortcuts using the same dialog. Script Shortcuts... Edit a special script (titled #keys#) that contains subroutines to be mapped to key shortcuts. The subroutines cannot reference each other or any global variables. For instance, to define a shortcut for the 'c' key you would put the following code into the script: [c] code ;

 About... Displays information about RPN. Help Toggle the help mode ON and OFF. When help is on tapping a script command will display its help string though not all scripts have help strings. Copy Copy a single number from the stack to the clipboard. Paste Paste a single number from the clipboard onto the stack. Modes... Open the format modes dialog box. Set Colors... Set the colors used for the main display.

## Using Graffiti or Keyboard

Most keyboard and Graffiti actions do the obvious thing. For instance entering '+' is the same as pressing the Addition button. The least obvious shortcut is that entering a space is the same as pressing the +/- button (this is because the Graffiti stroke for space looks like a minus).

# Basic Calculation

## Entering Numbers

Numbers can be entered using fixed, scientific, or engineering notation regardless of the current display mode. Pressing the EEX button will add the scientific part to the number, while the change sign button (+/-) will change the signing of whichever part of the number you are editing. Pressing the delete button while editing numbers deletes just the last digit of the number.

Pressing the EEX button to start a new number will automatically begin the number with "1e", which simplifies entering numbers like 1e6.

## Formatting Numbers

Choosing Modes... from the Extra menu or tapping the left side of the input line (around the trig mode display) will bring up the following dialog where you can define how numbers are formatted for display:

Trig Mode
Which units are used for degrees.
Comma Mode
Which character to use for the comma separator. The decimal separator will adjust automatically.
Number Mode
Which format to use for numbers.
 Fixed Scientific Engineering 10,000.12 1.00012e4 10.00012e3
Places
How many places to show after the decimal point. Tapping Places allows you to choose from common options.
Base
What numerical base to use for numbers. Tapping Base allows you to choose from common options.
Show Trailing Zeros
Set whether extra zeros after the decimal point are shown. (example: 1.0100 vs. 1.01 both with Places set to 4)

## Performing Calculations

Calculations are preformed by pressing buttons in the main display, choosing scripts in the script area, or entering key shortcuts via Graffiti or the keyboard. All calculations happen immediately and operate on the currently visible stack. In this way, postfix calculation is more immediate and separate from numerical data than infix or algebraic computation.

## Built-In Scripts

The built-in scripts are installed when you frist run RPN and appear in the upper-right of the RPN display. You can page through scripts with the scroll buttons on your handheld or select a script using the script popup button, the button with a little triangle on it (just above the Enter button). The usage of each built-in script is described below (only the more complex operations are covered in detail):

### Trig

 A collection of trigonometric functions and operations. RD ( deg --> deg* ) Presents you with a dialog to choose between converting to radians, degrees, or into the current mode of the RPN display. Hyp ( x --> f(x) ) Choose between various hyperbolic trig functions.

### Logs &Powers

 Logorithmic and exponential operations. >N ( N --> ) Set the value for N used in the next two functions. N^X ( X --> N^X ) N to the power of X logN ( X --> logN(X) ) Take the base N logarithm of X.

### Convert

 Over 400 conversions of various units. mass, temp, len, area, vol ( unit1 --> unit2 ) Choose two units and a conversion from the first into the second is made. again ( unit1 --> unit2 ) Repeat the last selected conversion. back ( unit1 --> unit2 ) Reverse the last selected conversion.

### Base

 Do calculations in different numerical bases. >B ( base --> ) Set the displayed base to any value in [2, 32] (the display can get a bit confusing in bases greater than 16 if you aren't used to it): 2 = binary, 8 = octal, 16 = hex. +, -, *, /, ,|, ^ ( Y X --> b(Y,X) ) Basic binary operations. <, >, ~ ( X --> u(X) ) Basic unary operations. A-F ( --> ) Enter Hex digits A-F if you are in a base which supports them (greater than base 10 obviously).

### Time

 With this script you can do arithmetic on time values and use clock and stopwatch features. All calculations are done in h.mmsstt format; meaning time is packed into parts of a decimal number so that 12 hours, 4 minutes, 29 seconds, and 30 ticks (1/100th sec) would read 12.042930. Now ( --> current_time ) Report the current time. Go ( --> ) Start the stopwatch. Since ( --> elapsed ) Report the elapsed time since the last Start without stopping the stopwatch. ( h.mmss --> ) Set a countdown alarm. The alarm can be Off, Running &Shown, or Running &Hidden. If the handheld is on and this script is visible then an alarm will go off when the timer completes. Note: this timer will not turn the haldheld on when it goes off, but it will continue when you come back to the Time script even if you change applications. /, x ( timeY X --> b(timeY,X) ) Divide or multiply in time format. Note: X is a regular number not a time. -, + ( timeY timeX --> b(timeY,timeX) ) Subtract or add in time format. dec ( h.mmss --> decimal_time ) Convert from h.mmss to decimal time format. h.ms ( decimal_time --> h.mmss ) Convert from decimal to h.mmss time format. >> ( time --> shifted_time ) Shift decimal places 2 places to the right. For instance, to enter 47 seconds: tap(4, 7, >>, >>)

### Finance

 Time value of money (TVM) calculations are done using 5 main variables: present value of money (pv), effective interest rate (i), payment amount (pmt), number of periods (n), and future value of money (fv). If you know 4 of these values, then this script allows you to solve for the 5th one. Note: The interest period and payment period is the same in these calculations to simplify the interface; you will have to convert your payments and interest into the same period. Note: If the interest rate is zero then you should just use the obvious calculations. Solving for extremely small interest rates (below .0001%) is not supported in this version. Note: Interest is entered and reported in decimal form, so that 6% interest is 0.06 Note: As usual in these calculations, money you have is positive and money you don't have is negative. Short Example: Let's say you want to invest \$1,200/year for 10 years and need \$40,000 at the end of that time to build your very own robotic pirate. How much interest are you going to need to earn on your investment? tap(mem, clear), -1200 tap(set, pmt), 10 tap(set, n), 40000 tap(set, fv), tap(calc, i) = 25% interest/yr! Let's say you're willing to start with \$10,000. -10000 tap(set, pv), tap(calc, i) = 8.3% interest/yr. Now that's a more likely way to acheive your goal. TVM ( --> ) Set the modes of TVM calculations using dialogs. You can specify when payments are made in the period and whether calculated values automatically are set after calculation. i% ( i --> i* ) Convert between Nominal and Effective interest. mem ( --> ) Save, recall or clear all the TVM settings and values. view ( --> varies ) View one or all of the 5 stored values. set ( varies --> ) Set one or all of the 5 stored values. To set all you need to put them on the stack in the order listed in the 'set' dialog. calc ( --> result ) Calculate one of the 5 TVM values using the other 4 stored values.

### Misc

 Miscellaneous functions. mod ( Y X --> Y%X ) Remainder after dividing Y by X. ip ( X --> ip(X) ) Integer part of X. fp ( X --> fp(X) ) Fractional part of X. ! ( X --> !X ) Factorial of X. % ( Y X --> Y Y(X/100) ) Take X% of Y, leaving Y on the stack. %% ( Y X --> delta(Y,X) ) Percent change of Y becoming X. stats ( ... --> stdDev mean sum N ) Calculate statistics about the list of numbers on the stack.

## Undoing Actions

You can undo the last actions effect on the stack by choosing Last Stack from the Stack menu or by dragging the 'Delete' button to the input line (which is directly to the left of the 'Delete' button). Note: effects on variables in scripts are not undone.

## Recordings

Also see recordings button and the next section for a Graphing discussion.

The sequence of actions to make a recording for the function f(x) = x*x + 7 is given below:

1. Enter a starting value and press enter. Note, the starting value is not part of the recording since you want the recording to operate on any value from the stack.
2. Select 'Record' from the 'Recordings Button'.
3. Press 'Enter' to duplicate the value.
4. Press the 'Multiply' button.
5. Press the '7' button.
7. Select 'Stop' from the 'Recording Button'.

## Graphing

Once you have recorded a function that produces a value for Y (see above), RPN will graph and solve it by supplying values for X and then runing your recording. Select 'Graph/Solve' from the 'Recordings Button' to view the graph. To return to the main calculator display simply tap the 'Done' button.

### Axis Tools

Found along the top of the display, the Axis Tools allow you to adjust the graph view with a single tap:
Axis:
Manually set the bounds.
In
Zoom-In by 2x.
Out
Zoom-Out by 2x.
Auto
Adjust the view so the graph fits.
Home
Go to the home view [-1, 1].

### Pen Tools

At the bottom of the display, the currently selected Pen Tool determines what happens when the pen is drawn over the graph:
Probe - f(x)
Tracks the pen in the graph and displays values.
Box
Drag out a rectangle and the graph will zoom-in to that view.
Drag
Drag the pen to move the graph within the view.
Center
Choose a point on the graph to center in the view.

## Solving

The probe tool displayed beneath the graph is used for solving as well as the reporting values. When the = button is pressed, RPN attempts to find an x value for the function graphed that equals the number in the field to the right of the button.

Within the graph display you can solve for the x-value corresponding to a target y-value:
1. Display a portion of the graph where the desired solution exists.
2. Allowing RPN to graph all the points may increase the success of solving.
3. Write the desired value in the field to the right of the = button.
4. Press the = button.
5. If valid starting conditions are found, RPN will display the result to the left of the = button.

# Scripts

## What are scripts?

RPN is programmed in a language called RPN-Code. Each script presents its own interface (the buttons in the upper-right in RPN) and is defined by loading RPN-Code written using the built-in script editor or an external editor.

## Navigating Installed Scripts

There are three ways to navigate between different scripts:
• Scrolling through them with the scroll keys on the device.
• Selecting one from the Script Button popup.
• Activating a script that executes a navigation action. This is an advanced topic covered in the programming section, see Misc Bytecodes.

## Finding and Installing Scripts

The best place to find scripts is the RPN Coweb . Once you've found a useful script database simply hotsync it to your device. The next time RPN is run it will be imported. In order to see that it is installed you may need to navigate to it.

## Managing Scripts

You can change the order of scripts and delete unwanted scripts using the Script Menu.

# Script Programming

Open the scripting manual.

# Glossary

nos
Next On Stack. The second value on the stack.
RPN-Code
The language used to write RPN scripts.
stack gauge
The vertical bar between the stack and script areas which indicates how full the stack is.
tos
Top Of Stack. The first value on the stack.

# Changes by Version

Version 3.61 -gt; 3.62 changes:
• Recordings now remember and replay the choices made in dialogs rather than present the dialog again.
• Fixed About... dialog display in Palm OS 3.x.
• Fixed key shortcuts for + and x^2.
• Improved accuracy of temperature conversions involving F degrees.
• Fixed Reinstall All... scripts menu action.
• Added 'UDx' bcode to queue up the choice for the next dialog.
Version 3.60 -> 3.61 changes:
• Fixed timer problem with About... Dialog.
• Fixed small drawing error.
Version 3.55 -> 3.60 changes:
• Improved and expanded built-in scripts:
• New Time Value of Money (TVM) functions.
• New Conversion script with over 400 conversions.
• New Time script with time arithmetic.
• Updated manual with script descriptions and new scripting information.
• Improved RPN scripting language:
• New RPN.4 format.
• Valid subroutine names in RPN.4 code are any combination of printable, non-whitespace characters *not* in this list: "()'[]`{};
• New RPN version bcode: Mv
• Scripts can have upto 255 globals now, accessed with the x@ and X@ bcodes and defined in groups of 10 by capital letters in the header: RPN.4.B = 20 globals
• Subroutines have precedence over locals now.
• Added single character subroutine calls by name.
• Depricated .set and .make for local variables.
• Added "=name" syntax for setting locals.
• Local variable names restricted to [a-z|0-9|A-Z] and cannot start with a digit.
• Depricated RPN.3 syntax because RPN.4 syntax is easier to use.
• Return stack increased to 128 elements from 12. i.e. More recursion depth.
• Fixed bug in using locals of same name in diffent scripts.
• Changed the button for breaking into a running script from Enter to the Record button.
• Removed warning on tapping empty stack location.
• Changed Ok-Cancel confirmation dialogs to Yes-No dialogs.
• Script editor does not ask for Save confirmation unless title has changed.
• Removed Clock and Timer scripts (still available on the RPN Coweb).
• Export files can be imported, deleted, or preserved when RPN runs.
• Fixed removal of multiple scripts after importing at the same time.
Version 3.51 -> 3.55 changes:
• Fixed hotsync problem with older versions of Palm Desktop by making RPN multi-segment.
• Fixed bug in deleting scripts.
• Fixed incorrect link to bytecodes in manual.
• Fixed sin(90) error.
Version 3.50 -> 3.51 changes:
• Updated interface and added tools for graphing.
• Fixed bug with ==, >=, <=, and != commands in scripts.
• Fixed export of databases from editor.
• Fixed initial insertion point focus in editor.
• Updated graphing documentation.
Version 3.22 -> 3.50 changes:
• Built-in Script editing.
• Easy import and export of scripts.
• Fixed color customization bug in OS 3.5, 8-bit devices.
• Beaming of scripts from script editor.
• Added ability to reset the key shortcuts and fixed potential endless loop after setting key shortcuts.
• tan(90) = numerical error now.
• Added end of script string, #end#.
• Key shortcuts can also be scripts defined in the "#keys#" script.
• Moved code entry into About dialog.
• New pricing structure, \$29 professional, \$19 student.
• Added word based commands to RPN-Code.
• Store (Z) and recall (z) stack bytecodes. Nop bytecode, `
• This manual.
Version 3.21 -> 3.22 changes:
• Fixed graphing bug caused by compiler optimization.
• Fixed occasional bug in dragging, particularly on OS 3.1.
• Fixed problem with trace popup in some Sony devices (PEG-SJ30).
• Added Home button to graphing bounds form.
Version 3.20 -> 3.21 changes:
• Hi-Res icon for soft-graffiti display.
• Fixed dialog button selection problem.
Version 3.10 -> 3.20 changes:
• High Resolution support for main display.
• Customizable colors for main display.
• Dialog for user defined shortcut keys. Simplifying previous system.
• Fixed sound bug in dialogs.