More Palm programming

As a first experiment in Palm programming, I’m porting my friend Jeff Duntemann’s Mortgage Vision program.  Jeff originally wrote the program in Borland Pascal (or was it still Turbo Pascal back then?) to explore the Turbo Vision application framework.  He and I (mostly he) later converted parts of it to Delphi for inclusion in our Delphi Programming Explorer, and then I converted the code to C++ for the C++Builder Programming Explorer.  It’s another one of those learning programs that’s relatively simple but makes use of many programming language features.  It’s a good learning tool.

So I immediately run into one of the Palm’s minor weaknesses–floating point.  The computer can do floating point math okay through emulation, but there isn’t really a math library.  The floating point library supplies addition, subtraction, multiplication, and division.  And a routine that’ll convert a text string, “123.45” for example, into a floating point number.  There aren’t any math functions, though, and the only output function displays the number in scientific notation.  Ugh.

Fortunately, the only math function that the mortgage program requires is pow()–raise a number to an integer power.  That was easy enough to duplicate.  Outputting a floating point number is going to require a little more work.  I guess I could include the standard C sprintf() function, but that seems like overkill.  I’ll probably dig into their Calculator source example and see if I can come up with a decent number formatting routine.

Don’t you love embedded systems programming? 

Fitaly Stamp

I had planned today to write about watching the Leonid meteor shower.  But when I went outside at 3:00 this morning it was completely overcast.  Bummer.  It was cloudy all week during the Mars approach last June, too, and I had my telescope all ready to check that one out.

A couple of weeks ago I mentioned a utility for the Palm computer called FItalyStamp–a keyboard overlay that covers the Graffiti area on the Palm with a custom keyboard layout that was designed to minimize pen travel.  I downloaded and installed the software, and glued a laser printer copy of the keyboard layout onto the data input area of my Kyocera phone.  After just a couple of days working with it, I was hooked.  This is much better than trying to write in Graffiti.

The registered product, which you can order online with your credit card, cost $35.00 plus $6.00 for Express Mail shipping.  The package arrived two or three days later with the diskette, a small printed manual, and four nicely-printed keyboard overlays.  My phone is slightly smaller than the Palm m100, so I had Debra do some creative trimming of the keyboard overlay, but other than that I’ve not had a single problem with the setup.  I haven’t reached the 50 words per minute data input rate that their marketing hypes, but I’ve achieved a sustained 20 wpm with some forays up toward 30 wpm.  It’s the next best thing to having a real keyboard hooked to the Palm.  Tapping on keys beats scribbling goofy letters hands down.  Try writing Graffiti on an airplane in moderate turbulence.  Tapping keys, I was able to make notes with a minimum of errors.  I can “type” with the fitaly keyboard almost as fast as I can write on paper.

Highly recommended if you’re doing any data input on your Palm.

Palm programming books

If you’re interested in programming for the Palm OS, pick up the book Palm OS Programming Bible by Lonnon R. Foster, published by IDG Books.  This book has everything you need, not only to get started, but to complete complex Palm applications, including writing the conduit program to communicate with your desktop computer.

I’ve read good things about Palm OS Programming, 2nd Edition, by Neil Rhodes & Julie McKeehan (O’Reilly), but have been unable to find it in the bookstore.  I’d order it online, but I’d like to thumb through it first.  I saw a copy of the first edition in the bookstore today–and liked what I saw–but I’d like to see the new edition in print before I spring from it.

I also picked up Robert Mykland’s Palm OS Programming from the Ground Up (Wiley), which promises “open this book as a Novice and finish it as a Pro.”  I should have looked more closely at this one before I bought it.  It covers most of the topics (although conduit programming is suspiciously absent), but does so in the context of an ongoing tutorial.  In order to understand Chapter 6, for example, you must have read and understood Chapter 5 and the code presented there.  This kind of book is fine, I guess, for somebody who has the time to sit down and do the tutorial, but the book is worthless as a reference or a quick study guide.  The explanations are more often of the code rather than the underlying APIs or data structures.  I prefer small examples that illustrate a single point rather than monolithic examples from which it’s difficult to glean small nuggets of information.  For sure don’t buy this book before you buy the Foster book. 

More on Palm programming

The Palm programming experiments are moving along nicely.  I’ve successfully created a “Hello, World” application just to get used to the development environment and such.  My initial impression still stands:  Writing a program for the Palm is very similar to writing to the Windows API.  We’ll see if that impression holds as I continue my experiments.  I’m starting on a “real” project and will report back as I learn things.

As I said (see November 3), I’m doing my initial experiments using Metrowerks CodeWarrior version 7.0.  It’s a little strange going back to C after writing Delphi programs for the last two years.  I could go with a Pascal development environment, and I may yet decide to do that.  The GNU PRC-Tools package targets the Palm, and I assume one could use the gcc Pascal compiler rather than the C compiler.  I read somewhere that Free Pascal will target the Palm, but haven’t been able to confirm that.  Finally,  there’s PocketStudio from Pocket Technologies–a commercial Pascal-based Palm development environment.  I’ve downloaded their trial version, but have not yet tried it out.  At almost $400, I’d need a real good reason (like a paying project, or maybe just a real strong aversion to C) before I could justify switching from the Metrowerks environment.  My toy budget just isn’t all that big these days what with the back room conversion and all. 

Programming the Palm

I spent the day trying (and mostly failing) to get a little “Hello, world” application to run on my new Palm Powered Phone.  (I was going to call it P3, but people would probably confuse that with a Pentium III.)  I downloaded the Palm OS Emulator (POSE), and used the ROM Transfer application to transfer the ROM image from my phone to the PC.  Loaded the ROM image into POSE, and POSE reports an error.  Kyocera apparently didn’t want to make their ROM compatible with POSE.  Sigh.  Now I’m waiting for Palm to approve my developer application so that I can download a ROM from them.  I won’t be able to emulate applications that use the Kyocera phone APIs, but at least I’ll be able to emulate standard Palm applications–which is all I’m after for the moment.

What little I’ve seen of the Palm API looks reasonable.  Writing a Palm application in C looks very similar to writing a Windows application.  The OS calls your PilotMain function, initializes everything, and sets up a message loop that continues until it gets the appStopEvent.  That’s about as far as I’ve gotten.  The sample application that I built from this page (Palm OS Programming, 2nd Edition) resulted in a crash that forced me to reset my phone.  I suspect I’ll be doing that a lot.

For the moment, I’m using Version 7.0 of Metrowerks CodeWarrior for Palm OS to do development.  I’ve always heard good things about CodeWarrior, but until today had never tried it.  I guess it’s possible that the compiler is technically superior to Borland’s or Microsoft’s, but the IDE does not compare favorably with either.  Borland’s IDEs have always been helpful and intuitive, and Microsoft’s a little less so to the extent of being downright aggravating at times.  But the CodeWarrior IDE is almost unusable.  Some things that should have right-click menus don’t, project defaults result in projects that won’t build, and the overall interface feels hacked rather than designed.  To make matters worse, the online help (presented in Microsoft’s abominable HTML Help format with “Help on Top” as a permanent default), is awful.  All of the examples show either a Mac OS or Windows project–not a Palm project to be seen.  Arrrgh!

Yes, some of the above is undoubtedly my frustration with a new programming environment and unfamiliar tools.  I’m having fun.  Let me rant!

I have also downloaded and installed the demo of a product called NS Basic, which is a Basic language development system for the Palm platform.  I’ve not yet actually done anything with it though, and hesitate to invest much time in what is essentially a p-code interpreter for the Palm.  You install the runtime interpreter (size: 88 K bytes) on your Palm, and then you can run any NS Basic application.  Having lived through the problems caused by multiple incompatible versions of the Visual Basic and Visual C++ runtimes, I’m in no big hurry to make my applications dependent on a third party runtime interpreter.  There is an option to include the runtime system (called “Fat Applications”) in your applications so that you don’t have to install the NS Basic interpreter, but that’s too much overhead on a memory-limited device like the Palm.  But then, I’m a C programmer.  If I was coming to the Palm with no C programming experience, I’d likely go the NS Basic route.  There are also versions for Windows CE and the Newton, giving the real possibility of writing a cross-platform handheld application.  I’ll probably take a look, but likely won’t do any serious development with it.