Figure 8. My Palm device with cradle.
In addition to the event()
procedure, the Event System
contains several other useful
functions, including the penx()
and peny() procedures. These
are two procedures you’ll probably be calling a lot if you create a Palm GUI. To put it
simply, these procedures return the x and y position of
the pen (or stylus).
Let’s say that your program calls the event()
procedure, which, in turn, returns the value 2 (pen down
event). Now, all we know is that the pen is actually
touching the screen. Maybe this is enough for some
cases, but — most of the time — you’re going to want to
know where the pen is touching the screen. To do that,
simply call the penx() and peny() procedures and they’ll
tell you everything you need to know.
Now, you’re probably aware of the fact that, when you
Figure 9. All you need to easily develop
Palm applications. Neither the computer
nor the Palm has to be very powerful.
press the “Calendar” button or any other
short cut button, the appropriate application
loads up automatically. This is because Palm
OS is constantly checking these buttons ...
even when your program is running. So,
ordinarily, even though you’re calling the
event() procedure to check for the status
of these buttons, Palm OS will take over the
second any of them are pressed.
That’s where the hookhard()
procedure comes in. If your program needs
to use these predefined buttons, you’ll have
to call this procedure before anything else is
done. If you pass a 1 to this procedure, all
of these buttons will be processed through
the event() procedure before going
through the OS. Otherwise, as I mentioned
before, as soon as any of these keys are
pressed, the OS takes over and launches
Orbworks is the developer of PocketC. On their site, you can find
information on PocketC, as well as other tools related to it.
Plus, they have a great support forum. So, if you have a question,
you can always ask.
Palm’s developer site. Everyone interested in developing
for the Palm should visit this site.
Even though I didn’t talk about PToolBoxLib in this article, I have
to mention it. PToolBoxLib is a free graphics library for PocketC.
Basically, if you want to do anything involving graphics in
PocketC, you need PToolBoxLib.
My robotics website. If you have a question,
don’t hesitate to Email me.
Easy string manipulation is often a weak spot in C
compilers, but this is not the case in PocketC! In fact,
working with strings is as easy as working with any other
variable type. Just define them and you can set them up
as easily as an integer. Of course, this isn’t nearly enough
for more advanced programs, so PocketC packs a bunch
of easy-to-use string procedures.
Included with these procedures is the strlen() procedure,
which returns the length of the string. Also, the strupr()
and strlwr() procedures are available to you. These
procedures will return any string you pass to them in either
uppercase (if you use struper()) or lowercase (if you use
strlwr()). On top of all that, you can also call the strstr()
procedure, which will actually search through a string for a
substring. If the substring is found, the procedure will return
the starting character position of that string.
NUTS & VOLTS
Of course, a compiler is only as good as its math
capabilities and PocketC packs quite a punch in this area.
However, while PocketC has several math functions, this
functionality doesn’t come naturally to the compiler.
Instead, all of the math procedures are defined in an
external library that you will need to install. Remember
when I told you that there are no external libraries to
install? I lied.
Well, actually, not really. I meant that you didn’t need
any external libraries to get started. However, if you want to
add functionality to the compiler (and I’m sure you will), you
will, of course, need some external definitions for things.
Fear not, though, for MathLib is here! In fact, MathLib
actually comes with PocketC, meaning that, when you