Welcome to this, the first in a series of articles on Palm development. So why Palm ? In my case, the decision was customer driven, however the reason for the customers decision was that the Palm platform is widely accepted, inexpensive and easy-to-use. Although I was initially cynical, I have to say that I have come to love the platform also. For me as a developer the reasons are somewhat different. The Palm platform gives me the opportunity to write code for a platform where speed is not so easy to come by, where resources are limited, and where code needs to be tightly written in order to be usable at all. I hope that excites more people than it scares away, it's certainly not all bad news. While the platform is certainly not as powerful as your desktop PC, you still are able to develop code on your desktop, using modern tools and compilers. The purpose of this first article is simply to provide an overview of Palm development, and discuss some of the options that you will have if you decide to develop for it.
I can't afford a Palm
It doesn't matter if you don't have a Palm handheld unit, because the people at Palm kindly provide a Palm emulator which runs on your desktop, is integrated with common IDE's, and even provides debugging support. The bad news is it does not come with any ROM's, which basically means it's useless. Palm provide a developer program through which you can gain access to ROM's, but if you are outside the US this involves filling in a form, which I sent off months ago and got no reply. The emulator does come with a utility for downloading a ROM to your desktop, which is what I eventually did. The link for the emulator is with the rest of the links, at the end of the article.
It is possible to code for palm in many languages, including Java, basic, C++, or using a number of R.A.D. environments. However, as I have already said, the palm platform is not highly powered, and for that reason I choose to develop for it in straight C. There are a number of C++ class libraries which seek to provide a MFC style wrapper around the C API. I chose to reject this approach even when it claimed to be lightweight because to do so would cut me off from the mainstream in terms of literature and support, and tie me to a product whose lifespan I could not predict.
There are a number of compilers available for palm development for Windows. The two most common compilers are probably CodeWarrior and GCC. There are a number of other compilers available, most of which use GCC to do the actual compiling. Of those I personally chose to purchase developer studio from Falch.net. My reasons were that the IDE is very similar to Visual C++ 6 which made it easy to learn to use, and I found it much more intuitive than CodeWarrior. However, that does not mean that my choice should be your choice, and I recommend you investigate the various compilers available. CodeWarrior has the advantage of being the industry standard for palm, GCC has the advantage of being free. So long as you choose a compiler which will build palm programs written in C, you will be able to follow my tutorials. Certainly, if you're looking for a free option, the demo of the Falch compiler should do you for much of the tutorials.
I guess if there's one point I intend to labour, it's that developing for palm means writing optimized code. This is so much the case, that the palm API provides alternatives to functions from the sea runtime library, in order to avoid code bloat caused by linking to that library. The following table lists a number of C functions and their palm equivalents. Print this out and put it somewhere prominent. You will refer to it often.
|C Function||Palm API Equivalent|
You will notice that unlike the standard library, the Palm functions feature a lot of capitalisation, and that the string functions all begin with Str, and the memory functions all begin with Mem. This is a common theme in Palm development, and you will find that each library in the Palm OS has its own prefix for all functions found in it.
Your developer ID
Another quirky thing about Palm development is a simple fact that your hard drive is your RAM. This is actually an area where performance can be good, because to search through your record set does not require any mechanical process, simply locking of areas of memory and direct access. This does however mean that in theory your application has access to all of the programs and data on your unit. The reason this is not the case is a mechanism whereby you need to know some information about a database before you can gain access to it records. Part of this mechanism involves the assignment of a unique, 4 letter ID. The process is simple, it just involves entering your proposed ID on the Palm site, where you will be advised if the ID has been assigned to you or was previously assigned. The ID must be in capital letters, as all lowercase letters are reserved for use by Palm.
As you may be aware, the Windows API expects a function called WinMain, rather than main as its initial entry point. The Palm API continues the tradition, its entry point is known as PilotMain. The reason for this is that the original Palm product was called the PalmPilot. Believe it or not, I finally going to show you some code.
Hello Palm Pilot
UInt32 PilotMain (UInt16 launchCode, MemPtr launchParameters,
if (launchCode == sysAppLaunchCmdNormalLaunch)
WinDrawChars( "Hello, world!", 13, 55, 60 );
EvtGetEvent( &event, evtWaitForever );
SysHandleEvent( &event );
} while (event.eType != appStopEvent);
As we delve deeper into the Palm API in the coming articles, you will come to realize how much of a barebones example this is, nevertheless it is customary to begin teaching with such example, and who am I to break tradition ? Even so, there is much to be learned from this example. For starters, the Palm system is event driven. I'm sure this hardly comes as a surprise. What may be more surprising, is that the Palm defines its own types. The reason for this is simple: the Palm can be developed for on any system that offers a C compiler. That being the case, it is better that the Palm API provide guarantees regarding the size of numeric variables in particular, but also the nature of variables in general. The Palm API often appends the word 'type' to its types, as in the
EventType in this example. The event type is simply an event, which the API catches and in a full example passes to the menus and our own event loop as well as to the system. In this case we merely check the launch code to see if the application is being launched normally, draw our string and run a minimal event loop so that our program will respond when the buttons are pressed to move to a different program or back to the main screen. The next article will introduce forms development, that is to say building a GUI and an event loop to allow user interaction. I know it's a lot of work to get to the point where you have everything you need and can build Palm apps, I promise you that it's worth it. I've had a lot of fun getting to the point that I can write these articles, I hope you have as much fun joining me.
- www.palmos.com - This is where to go for the Palm SDKs and to sign up for the developer program to get the ROMs for the emulator. The emulator and other tools are also available here, but you may get them with your compiler
- Code Warrior - The standard for Palm development, but in my opinion a little pricey and hard to use
- www.falch.net - In my opinion an excellent product, comes with the emulator, etc. and the demo is not time limited ( although it is limited in other ways )
- news://news.falch.net - The people who made my favorite compiler also host a news feed full of information about Palm.