message). For this, you can use the alert()
command, which will actually create a separate
dialog box and output the text there. Even better is
the confirm() command, which not only creates a
separate pop up box, but also adds “Yes” and “No”
buttons. Using this command, you can easily receive
user input without any hassle.
This should be enough “basic” output
commands for most programs, but what about
input? While not all programs require any input, most
do, and PocketC equips the programmer with several
of these much needed commands. First and
foremost is the gets() command. When this
command is called, the Palm will create a new input
box with two buttons: “OK” and “Cancel.” Here, the
user of your program will be able to type in an entire string
that the gets() command will return if the user taps “OK.”
If the user taps “Cancel,” then the procedure returns an
empty string. Not only does this procedure create a simple
input box, but you can also give the procedure a string of
text to print out on the screen.
For example, gets(“Type in something”), when run
will create a pop up box asking the user for input.
However, the text inside of that box will read, “Type in
There are also several gets() variants, such as the
getsd() procedure. This new procedure does the same
thing as gets(), except that you can give the input box a
default value. Also available to you are the getsi() and
getsm() commands, which act like the original command,
except that you can tell PocketC exactly where to place the
input box (instead of the default bottom of the screen). The
getsm() procedure also adds the ability to control the size
of the input box in addition to the other features of the
Figure 6. A screenshot showing the
Figure 7. A screenshot showing
the resulting memo file from the
“Creating Memo Files” section.
We now know how to output text to the screen and
receive user input, but how do we know what the user is
doing to the Palm at any given time? For example, a
program might need to know when a user taps the screen
or presses the “Calendar” button. This is all handled
through the Event System in PocketC.
While there are several commands that can be
considered a part of the event system, the command you’ll
probably be using most is the event() command. This
command will basically check to see what the user is doing
and report back with the number code of the event. Say,
for example, the user taps the screen. The event()
procedure will return the number 2. Later on, however, the
user presses the Page-Up key. In this case, the event()
procedure will return a 5. All in all, there are 18 different
events that this procedure can track. If you need to know
what they all are — and I’m sure you will — take a look at
the PocketC documentation.
Circle #125 on the Reader Service Card.