|
|
|
|
|
|
|
|
PROGRAMMING POWER
Hello World!
By Alan Jay Weiner
Note on program listings PalmPower is still a growing journal. And as such, it occasionally has growing pains. In this case, the growing pains relate to how it displays program code in your Web browser. PalmPower is created using a powerful and complex Journal Production System that performs all of the HTML code generation (including creating back issue lists, tables of contents, and even paginating articles). Unfortunately, raw C code apparently confuses the current version of the Journal Production System. Rather than leaving you without Alan's excellent code examples, we will simply be including links to individual, separate HTML pages containing the code. It's not as pretty as we would normally like, but it will get the job done until we can get the production software trained on the intricacies of C code. -- DG
|
In The C Programming Language by Brian Kernighan and Dennis Ritchie, their first example of a C program is the now-traditional "hello, world" program. This four-line program simply prints the words "hello, world" and exits.
K&R wrote it like this (see http://www.component-net.com/pp-extras/helloworld1.html).
Alas, life is not so simple any more - the classic "hello, world" program is quite a bit more complex when we code it for the PalmPilot.
PalmPilot applications generally don't start and run to completion without yielding control to the Palm OS operating system. Applications that fail to yield control prevent other things from working. For example, the user can't switch to other applications, power down, or do a "find." Most applications will start, display a screen, and then yield until they're told to do something. Usually the user will press a button, select a menu option, or some outside event will cause the program to do something. Such programs are "event driven". They do a little work each time some particular event occurs.
For example, when the built-in Address Book starts, it does some initialization, reads the first few data records, and displays a screen. It then pauses, handing control back to Palm OS until the user does something - perhaps pressing the "new" button. The button press is an event. The program then scurries off to do a bit of work before returning to the OS to wait for the next event.
This month, we'll look at an appallingly complex "hello, world" application for the PalmPilot. Step by step, we'll examine how this "simple" application works, walking through application start, exit, and the various events it receives and processes during operation.
|
|
|
|
|
|
|
|
|
|
|