All Topics, MFC/C++ >> PDA / Embedded >> General (Beginner)
An introduction to the Palm platform
By Christian Graus.
An overview of the Palm world, including a list of C functions which have preferred equivalents in PalmOS
|
C++, C WinCE, PalmOS, Windows PDA, Win32, VS Dev
Posted: 8 Nov 2002
Views: 74,230
|
|
|
Rating error: You must be signed in to vote | 17 votes for this article. |
| Popularity: 5.73. Rating: 4.66 out of 5. |
|
|
Introduction
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.
Languages
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.
Compilers
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.
C API
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 |
strlen |
StrLen |
strcpy |
StrCopy |
strncpy |
StrNCopy |
strcat |
StrNCat |
strcmp |
StrCompare |
strncmp |
StrNCompare |
itoa |
StrIToA |
strchr |
StrChr |
itoa |
StrIToA |
strchr |
StrChr |
sprintf |
StrPrintF |
svprintf |
StrVPrintF |
malloc |
MemPtrNew |
free |
MemPtrFree |
memmove |
MemMove |
memset |
MemSet |
memcmp |
MemCmp |
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.
int main()
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,
UInt16 launchFlags)
{
EventType event;
if (launchCode == sysAppLaunchCmdNormalLaunch)
{
WinDrawChars( "Hello, world!", 13, 55, 60 );
do
{
EvtGetEvent( &event, evtWaitForever );
SysHandleEvent( &event );
} while (event.eType != appStopEvent);
}
return;
}
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.
Links:
-
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.
About Christian Graus
| Programming
computers ( self taught ) since about 1984 when I bought my first Apple
][. Was working on a GUI library to interface Win32 to Python, and
writing graphics filters in my spare time, and then building n-tiered
apps using asp, atl and asp.net in my job at Dytech. After 4 years
there, I've started working from home, for Code Project and on an image
processing program for the Vet market.
Click here to view Christian Graus's online profile. |
Other popular PDA / Embedded articles: |
|
Note: You must Sign in to post to this message board. |
| | Msgs 1 to 21 of 21 (Total: 21) (Refresh) | First Prev Next |
| | | Author | |
| | Date | |
|
| | | freddy1ca | 4:34 4 Aug '04 |
|
| | | Christian Graus | 16:59 4 Aug '04 |
| Unfortunately,
they went broke a fair while ago. The product is no more, it has ceased
to be, it has joined the choir invisible. Apart from the very expensive
Code Warrior, I'm not sure what options you have anymore.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder | [Sign in | View Thread | PermaLink | Go to Thread Start] | Score: 2.0 (1 vote). |
|
|
|
| | | | Guilherme Hazan | 20:53 30 Nov '03 |
| Hi,
I'm now hosting the newsgroups pilot.programmer.*. The news.falch.net is definetively dead. Can you please update your homepage?
The new news server is: news://news.superwaba.net
And it contains the newsgroups:
pilot.programmer pilot.programmer.waba pilot.programmer.jump pilot.programmer.gcc pilot.programmer.pila pilot.programmer.codewarrior
Best Regards,
Guilherme C. Hazan (guich) SuperWaba Lead Developer http://www.superwaba.org "I program therefore I am" | [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Christian Graus | 21:35 30 Nov '03 |
|
| | | | Code4Food | 12:41 4 Dec '02 |
| Which
version of Falch.net did you settle on? I am interested in getting the
program and was looking at the personal edition which doesn't come with
the Visual database designer. Is the extra $100 worth it to get that
part of the studio? Thanks for your opinion very eager to try my hand
at Palm programming
Any reference or books you recommend on the subject as well? Sorry if I spoiled your article thread here with this OT question.
Code4Food ---- "There is no try; only do or do not" -Yoda
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Christian Graus | 14:46 4 Dec '02 |
| Code4Food wrote: Sorry if I spoiled your article thread here with this OT question.
Not at all - that's what the message board is for.
Code4Food wrote: Any reference or books you recommend on the subject as well?
The
two that always get a mnention are 'The Palm Programming Bible' and the
Palm Programming book from O Reilley, which I have, but cannot remember
the title of. They have three, one on programming the PAlm in VB (!),
one on network programming, and the third is the one I mean.
We
got the version with the database designer, and I wish we hadn't. I
don't use it, and would not bother paying extra to get it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | k6whp | 17:36 30 Apr '04 |
| As
of this writing, April 2004, if you are a beginner to writing Palm
applications, to *not* look to Falch.net as a development solution.
Sadly, it is not being supported any longer although, there is still a
link by which you might still buy the professional version.
This
is not to discredit the effort by Christian Falch in producing this
product in the least. It is an exceedingly nice IDE for the PRC tools.
It is with great sadness that I note no one has taken up the banner or
that this product was put into the open source category.
Just wanted you to be aware of this before you spent your money.
William Southern California | [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | | ruihuahan | 20:02 12 Nov '02 |
|
| | | Christian Graus | 20:34 12 Nov '02 |
| Thanks for the feedback - I hope to do an article on tables soon.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | | Massimo Colurcio | 14:03 9 Nov '02 |
| Great idea Christian.
I
appreciated your article 'cause I think Palm is a great PDA (for me
better than WinCE devices). My first Palm was PalmPilot 1000, now I
have a Palm IIIxe with an axxPac (up to 64MB with a single Smartmedia
card). Now I'm waiting for your next articles to learn how to access to
some Palm's intresting features (like datebook and addresses records).
Good job.
Massimo Colurcio mailto:m.colurcio@softhor.com http://www.softhor.com/developmentarea ICQ #96413649 ATIC #1219 SONORK 100.10862 | [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Christian Graus | 16:39 9 Nov '02 |
| Massimo Colurcio wrote: Now
I'm waiting for your next articles to learn how to access to some
Palm's intresting features (like datebook and addresses records).
*grin* I'll see what I can do...
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | | Mario M. | 11:11 9 Nov '02 |
|
| | | Christian Graus | 16:38 9 Nov '02 |
| LOL - WinCE is obviously the easy way out, but I'm of the opinion that Palm is much more interesting as a result.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | | Nishant S | 20:02 8 Nov '02 |
|
| | | Christian Graus | 21:07 8 Nov '02 |
| Thanks,
Nish. I contemplated not putting it up, but it covers some stuff that
Jason doesn't, as he also covered quite I bit I do not. Plus we offer
two very different Hello World apps, so I think that they are both of
value when put together.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | Score: 2.0 (1 vote). |
|
|
|
| | | | Gavin Greig | 6:30 8 Nov '02 |
| Great
to see a good introductory Palm article here. I'm sorry to hear you
haven't got a good response to your attempt to register for Palm ROMs,
but maybe you should try again - it is invaluable to have access to all
the different ROMs, particularly debug ROMs and the various
international ones.
I prefer C++, even for Palm development, but
have taken the approach of developing classes for string functionality
(for example) as I require them, rather than using somebody else's
framework. Metrowerks CodeWarrior does a pretty good job of keeping any
C++ overhead down - so far as I can tell, my application is only 2 to
4kb bigger than it would have been as a C application - the
overwhelming majority of the application size (47kb) is accounted for
by the resources (colour icons and a lot of strings).
Gavin Greig
"Haw, you're no deid," girned Charon. "Get aff ma boat or ah'll report ye." Matthew Fitt - The Hoose O Haivers: The Twelve Trauchles O Heracles. | [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Christian Graus | 15:16 8 Nov '02 |
| I
think I may do the same thing once I have been using the C API for a
bit. I dunno what the problem with Palm is in terms of getting ROM's,
but I suspect it's because I am not in the USA that they did not
respond.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Garth Lancaster (In Global Roam Mode) | 16:10 8 Nov '02 |
| Christian
- I doubt that its just because you're in Australia that they havnt
answered your query about PALM ROMS ... I signed up as a developer many
moons ago (From Sydney), and had access to POSE and the ROMS...
If
I could remember where I put them, I'd burn you a copy on my return to
Aus (next Friday, 15th), but I think they've been erased ... | [Sign in | View Thread | PermaLink | Go to Thread Start] | [Modify | Delete]
|
|
|
|
| | | Christian Graus | 16:15 8 Nov '02 |
| Hmm...
maybe I need to lie about the scope of our Palm plans then. We are
writing one app at work and that's about it. I guess I'll try again.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Gavin Greig | 3:54 11 Nov '02 |
| Christian Graus wrote: I suspect it's because I am not in the USA that they did not respond
That
may not help the response time, but I'm in the UK. I registered twice
successfully, once for work and once personally, and I was quite clear
about the personal application being exactly that.
Gavin Greig
"Haw, you're no deid," girned Charon. "Get aff ma boat or ah'll report ye." Matthew Fitt - The Hoose O Haivers: The Twelve Trauchles O Heracles. | [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
| | | Christian Graus | 4:17 11 Nov '02 |
| Thanks - I guess I really should try again then.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During
last 10 years, with invention of VB and similar programming
environments, every ill-educated moron became able to develop software.
- Alex E. - 12-Sept-2002
| [Sign in | View Thread | PermaLink | Go to Thread Start] | |
|
|
|
|
| Last Visit: 6:11 Friday 31st August, 2007 | First Prev Next |
|
|
General comment News / Info Question Answer Joke / Game Admin message
|
|