jHP49 Calculator Plugin By Slava Pestov & Romain Guy
sp@gjt.org - guy.romain@bigfoot.com

The calculator plugin implements a simple RPN calculator. There are to ways to perform a calculation.

The first way is to invoke Plugins>Calculate, which displays a dialog containing a five levels stack and a text field where an expression can be entered. Even if only 5 levels of the stack are displayed, the stack can contain much more. In fact, this first way acts exactly as the HP48/HP49 calculator in RPN mode.

The second way is to execute Calculator:expression from the console (or any other EditBus-aware plugin).


The calculator does not support infix notation (for example, 2 + 3 * 7). Instead, it uses the slightly harder to use but much easier to parse RPN notation (the above example would be written as 3 7 * 2 +). In RPN notation, the input is a sequence of tokens. Number tokens are pushed onto a stack, and function tokens operate on the topmost elements of the stack, replacing them with the result when done.

For example, consider the simple expression 3 7 * 2 +. Entering: 3 (enter) 7 (enter) * (enter) 2 (enter) + (enter) is equivalent. This is what actually happends when it is executed:


The following primitive functions are currently implemented: The following higher-level functions are also defined: Variables can be used to store values, in a slightly clumsy way. The get function retreives the variable named by the topmost element of the stack. The set function sets the variable named by the topmost element of the stack to the value of the next element.