Programming the Palmtop (Part II)

Like programs for other GUI operating systems (Mac, Windows, Palm OS, ...),
HP Palmtop System-Manager compliant application programs are
event-driven. This means that the System Manager will report
each important event to your program. Your program will spend most of
its time in a loop waiting for an event; when the event occurs, your
program will respond appropriately to it and then go back and wait for
the next event. Most of the event are keystrokes, but other events that
System Manager will send to your program include

deactivation

(when another Palmtop application is started up)

reactivation

(when your app regains control)

termination

(when System Manager is low on memory: the user is given a choice of
which open applications should be closed, and your app may be one of
those given the axe)

refresh

(sent if System Manager wants the screen redrawn)

"NONE"

(this message is sent at regular intervals, mainly to help keep the
date-time display in the title bar honest)

Much of the structure of a Palmtop app is also dictated by the Lotus
Handheld Application Programming Interface, or LHAPI. Like other
GUI operating systems, LHAPI provides many of the basic constructs for
Palmtop app user interfaces. The screen in a Palmtop app contains a
main window and child windows which appear and disappear as needed by
the program. Each window can be configured to perform different functions,
and LHAPI has many preconfigured windows to do everything from check boxes
and radio buttons to file selection dialogs and multiline text editing.
The data structures for LHAPI windows are described in the Developer's
Guide, and the disk provided with the Kit contains the C and assembler
header files needed to access the routines.

Below is a System-Manager compliant application program. In the Kernighan
and Ritchie tradition, all the program does is displays "Hello, world" (and
"Goodbye, world") on the screen. The comments are my attempt to explain
what is going on in each part of the code.