Product research made easy, visit eDistiller today!.
What & Why
rpnCalc is a reverse polish notation (RPN) calculator. The stack behavior is based, rather loosely, on the HP-28S. I originally wrote it because the battery on my HP-28S died and I needed a calculator. Yes, I suppose I could have bought a new battery. But instead I wrote an HTML/Javascript/CSS RPN calculator; partly out of need, and partly as an exercise in Javascript.
With the release of Tiger (OS X 10.4) on the Mac, comes the new Dashboard feature. This is actually a pretty cool feature and, much to my surprise, the dashboard widgets are created using HTML/Javascript/CSS. Since I like learning new things, I took my existing code and made the modification needed to turn it into a full-fledged widget.
I find it useful, I figured, perhaps incorrectly, that others might too. So here it is, an RPN calculator widget for the world at large.
Looking for a version for the iPhone or iPod Touch?
We've created the BigStack RPN Calculator which is based on the RPN Calculator widget. It's available on the iTunes app store (link will open in iTunes).
How to Download
For all the details on how to use widgets, consult the documentation on your Mac. Basically, you need to be using OS X 10.4 or higher. Click the icon below. If you are using Safari, the widget will install automagically. If you are using another browser, you'll need to unzip the downloaded file (which will then be called rpnCalc.wdgt) and put it in your /Library/Widgets directory. Then, when you start your dashboard you'll see the icon for the rpnCalc widget (shown below), drag it on to your dashboard and you are good to go.
Other Widgets
Check out my other widgets:
- encryptadoro — an encryption widget, handy for passwords and larger messages too.
- tipstrs &mdash shows the latest tips from tipstrs.
- eDistiller — product research from the comfort of your dashboard.
- arenaLaunch — a quick-launch shortcut for Arena PLM.
- wSpeak — the outlaw widget banned by both Apple and MacUpdate.
Copying from an OSX widget
rpnCalc offers commands which allow the stack values to be copied onto the clipboard. This functionality makes use of the pbcopy system-level command. So far as I can tell, there is a bug with this command. Sometimes when the copy occurs, it doesn't actually work. What I've found is that if I am in an application, I copy something from that application, and then I copy something to the clipboard from rpnCalc, if I then try to paste the rpnCalc result into that application it will fail; instead of pasting the newly copied content, it will paste the content previously copied in the application.
But there is a way to make it work. When this happens, go into another application and paste. You should find that the rpnCalc result is now pasted. If you then go back into the original application, if you now paste you will get the result from rpnCalc. Yeah, this is kind of lame, but it's the best work-around to the problem that I have found so far.
The Legal Mumbo Jumbo
This Software is freeware. I make no claims about it's accuracy or fitness for use. On the upside, you are free to use it in any way you see fit; I won't even take your donation, much less ask for it. In addition, you are free to use the code in anyway you like. Modify it to make your own calculator, use it to learn something about dashboard widgets, the possibilities seem endless and magical.
As part of the deal, Apple asks that I tell you the following...
Mac OS X v.10.4 Tiger is required. If you're using Safari, click the download link. When the widget download is complete, show Dashboard, click the Plus sign to display the Widget Bar and click the widget's icon in the Widget Bar to open it. If you're using a browser other than Safari, click the download link. When the widget download is complete, unarchive it and place it in /Library/Widgets/ in your home folder. Show Dashboard, click the plus sign to display the Widget Bar and click the widget's icon in the Widget Bar to open it.
Change History
For the history buffs amongst us, here is the content of the change log:
- Version 1.6.1 — December 13, 2006
- Fixed a bug whereby if a HEX value contained a single 'E' and no other non-numeric characters, it was being converted to a exponential number.
- Version 1.6 — September 16, 2006
- Added the ability to copy values from the stack into the clipboard. Please see the section above concerning copying from a widget.
- Added the ability to select from a list of several calculator styles.
- Corrected a bug where large numeric entries with commas could cause the stack area to widen, thus messing up the display of the widget.
- Updated the style so that messages as shown so that they completely cover the stack information, the stack no longer bleeds through.
- Version 1.5.1 — April 10, 2006
- Corrected a bug that was happening when numbers had commas added to them while in the precision number format; there were times when the commas were not being added correctly.
- Version 1.5 — March 26, 2006
- Updated the style so that the buttons stand out better.
- Updating the messaging of errors so that acknowledgement of the error is no longer required.
- Added the
hypotcommand, used to caclulate sqrt(x*x + y*y). - Added the
atan2command. - Version 1.4.4 — March 16, 2006
- Updated the handling of preferences so that they are actually remembered when the widget is closed or the machine is rebooted.
- Updated so that the 'Clear' button on the numberpad of bluetooth keyboards behaves like the 'Delete' button.
- Version 1.4.3 — February 3, 2006
- Updated the titles/hints for the commands that convert from decimal to other number bases to make it clearer that the resulting number is a decimal representation of the number in the new number base, not a number in the converted base. For example, when converting the number
16to Hex, the result is10. But if1is then subtracted from this value, the result is9, notF. - Version 1.4.2 — February 2, 2006
- Fixed a bug whereby it was possible to wedge the calculator by ignoring error messages and continuing to enter bad input. Now when an error message is presented, the calculator inputs are disabled until the message is acknowledged.
- Version 1.4.1 — February 1, 2006
- Fixed a very annoying bug. Previously, the numeric entry for the current input value had to be done entirely using the computer keyboard or the number pad in the calculator; trying to enter a number with some of the values entered manually on the keyboard and others entered using the calculator keypad resulted in a numeric jumble. This problem has been fixed.
- Version 1.4 — December 27, 2005
- Added new functionality for converting between number bases. It is now possible to convert from a decimal (base-10) number to binary, octal, and hex and from these other bases back to decimal.
- Added an indicator in the display to show the selected trig mode (degrees/radians).
- Updated the titles on the buttons to be marginally more informative.
- Now correctly updating the version number in the Info.plist file so that automagic updates to the widget occur as they should when new version of the widget are downloaded.
- Version 1.3 — July 1, 2005
- Added an option so that numbers can be formatted to include commas.
- Added an engineering format option. Using this format, the number is displayed in exponential format where the exponent is always a power of three (or zero).
- Corrected a bug in the display of exponential values in the range -1 < x < 0.
- Changed to a simpler background design on the back panel to reduce the size of the package that needs to be downloaded.
- Version 1.2.3 — June 16, 2005
- There is a bug in the Safari implementation of the toPrecision and toExponential methods of the Number object. Sadly, these are what I was using to display numbers in the 'precision' and 'exponential' formats. This has been causing issues in the display of certain numbers. For example, 0.01 would be displayed as 0.001. This doesn't affect the display when using the 'fixed' format. I've made an attempt to correct this by defining my own functions for showing the values when in 'precision' and 'exponential' modes. Hopefully this will correct the problems without introducing any new issues.
- By popular demand, update so that the 'esc' key can be used to clear the entire stack, even while entering a numeric value.
- Version 1.2.2 — June 14, 2005
- By popular demand, changed the x^y key to be y^x.
- Fixed an error in the display of exponential values. When the value was less than 1.0, the exponent was too large by one. So for example, 0.25 was displayed as 2.5e0 instead of 2.5e-1.
- Version 1.2.1 — June 11, 2005
- Corrected the behavior of the x^y key. Previously, it actually returned the value y^x.
- Version 1.2 — June 9, 2005
- Updated the section that shows the complete stack...
- It now has a header indicating the total number of values in the stack.
- It now doesn't disappear when the mouse moves into it.
- It now scrolls when there is too much information to display.
- The height of the element is fixed.
- Moved the location slightly.
- Added an opacity to the background.
- You can now paste into the input area.
- Corrected a bug that kept the '8' and '9' keys from working on the keypad.
- Version 1.1 — May 30, 2005
- Added an Undo command. At this point, it only undoes the last operation, but it's a start.
- Added keyboard shortcuts for every button. Also added a title attribute for all of the buttons that is set to the keyboard shortcut... this way you can hover over the button to learn the shortcut.
- Added additional checks to disallow keystrokes that are not "legal".
- Update the hover class for the buttons to provide additional emphasis.
- Changed the look of the back pane.
- Added version information on the back pane.
- Made a bunch of changes to be more in keeping with Apple's style guidelines...
- Moved the link to the back pane to the lower, right-hand corner of the page.
- Removed the title bar in the main application window.
- Added drop shadow to all of the images.
- Version 1.0 — May 19, 2005
- The initial release.