FAQ - Programming with the GNU Pilot SDK
Last modified:  Friday, March 13, 1998
Last posted:  Tuesday, March 10, 1998
Revision number:  463
Total lines in FAQ:  1698


                     T A B L E   O F   C O N T E N T S


0.  Intro / About the FAQ
0.1.  Maintainer of the FAQ
0.2.  Where can I find the FAQ on the Web?
0.3.  What is this FAQ all about?
0.4.  What do the [+++] and [***] mean?
0.5.  Where do you get the questions and answers for the FAQ?
0.6.  I've found a flaw in the FAQ / I want to submit a question or answer
      to the FAQ
0.6.1.  What do the ##'s in the FAQ mean?
0.7.  So who is this Sproat guy, anyway?
0.7.1.  So he's an expert, right?
0.8.  These questions and answers are way too simple for me.
0.9.  This bites / I could do a better job on the FAQ
0.10.  Tools used in writing the FAQ

1.  Stuff on the Internet
1.1.  Other FAQs and sources of information
1.1.1.  Pilot Software Development
1.1.2.  PalmPilot Development Resources at RoadCoders
1.1.3.  Wade's Pilot Programming FAQ
1.1.4.  The Responsive Knowledgebase for Developers
1.1.5.  The Pilot FAQ
1.1.6.  The Pilot developers' newsgroups at massena.com
1.2.  Other Pilot-related sites
1.2.1.  3Com/Palm Computing's PalmPilot Developer Zone
1.2.2.  Ray's PalmPilot Software Archive
1.2.3.  C & PILA Source Code Page

2.  About the utilities
2.1.  gcc / prc-tools
2.1.1.  gdb
2.1.2.  Copilot / XCopilot / Zilot
2.2.  PilRC / PilRCUI
2.3.  Emacs

3.  Install issues / Getting started
3.1.  How do I set up gcc in Linux or Windows 95/NT?
3.1.1.  Okay, so where do I find the tutorial / I deleted the tutorial
3.2.  I installed gcc to drive D: and now it doesn't work!
3.3.  I can't get this to work in Win32S (Win 3.x) / DJGPP (DOS)!
3.4.  Can I / How do I set up gcc for developing for the Pilot on the Mac?
3.5.  Where can I find some source code to look at?
3.6.  What is some good software to have on the side?
3.7.  Is there a utility to take care of creating the basics for a new app?
3.8.  How do I get the rest of the Emacs distribution?
3.9.  I'm getting the error message "Error while dumping state (probably
      corrupt stack) in cygwin_except_handler" when I use the SDK! [+++]

4.  Common pitfalls / Common questions / Not-so-common questions
4.1.  What are some of the most frequently-used command-line options for
      gcc?
4.2.  Can I use the GNU Pilot SDK to compile program sources intended for
      CodeWarrior?
4.3.  What does the gcc error DISP16 mean? [***]
4.3.1.  What does the gcc error DISP16 bzero mean? [+++]
4.4.  I have a PilotMain() function, but the compiler says that I don't!
4.5.  Why won't my global data work when I'm running a callback function?
4.6.  Where can I get a generic makefile?
4.7.  Why has my makefile stopped working?
4.8.  I entered a few lines of code, and now I can't use the 'find' feature
      of my pilot without crashing!  a.k.a.  My program crashes the Pilot
      when I _install_ it!  What's going on?!
4.9.  What does "#pragma pack(2)" mean?
4.10.  How can I reduce the size of my .prc file? / Why has my .prc file
       size increased dramatically?
4.11.  My local variables are overwriting my global variables! / Is there a
       limit to the size of local variables?

5.  Copilot / XCopilot / gdb / Debugging
5.1.  How can I debug with Copilot / XCopilot and gdb?
5.1.1.  I don't have an "example" directory / I can't find gdbpanel.prc!
5.2.  I'll just use Copilot / XCopilot to debug, thanks.
5.3.  How can I debug my program in Copilot on Windows NT?
5.4.  I downloaded Copilot / XCopilot from its original Web site, but I
      can't get it to debug with gdb!
5.5.  The lines in gdb don't match up with what my program's doing!
5.6.  I'm debugging and I can't see all of my variables!
5.7.  Why can't I edit database records in-place while I'm debugging?
5.8.  How do I compile a breakpoint into my code?

6.  API / Libraries
6.1.  What APIs are available?
6.1.1.  Can I use the standard C libraries?
6.1.1.1.  What does the Copilot error "palmos_GLib.c, Line:23, C Library is
          not installed" mean?
6.1.1.2.  The  functions aren't working!
6.1.2.  I can compile C++!  Is there a class library for the Pilot?
6.1.2.1.  I *can't* compile C++!  Where can I find information on getting
          this to work? [+++]
6.2.  What's this business about shared libraries?
6.2.1.  How can my app tell if a shared library is loaded on the Pilot?
6.3.  What's this business about dynamically creating your GUI?
6.4.  Can I use lex/yacc (or flex/byacc/bison etc.) in my Pilot program?

7.  Pilot Memory / Databases
7.1.  What, briefly, is a Database?
7.2.  What happened to malloc() / realloc() / calloc() / free()?
7.3.  What's this about a 32k limit? / How do I get around the 32k limit?
      [***]
7.3.1.  How can I find out how much code and data there is in my object
        file?
7.3.2.  Can I use a Database to simulate large memory chunks?
7.4.  How do I read a Database from, say, Memopad?
7.5.  Can I create a Database (.pdb file) from my PC instead of using my
     Pilot?

8.  Pilot Resources
8.1.  What, briefly, is a resource?
8.2.  Can I create resources without using PilRC?
8.3.  Can I mask field input to numbers like I can with CodeWarrior? [***]
8.4.  How do I dynamically add data to a List?
8.5.  I'm having trouble with Table.
8.6.  How do I create a Gadget?
8.7.  How do I force a Field to have focus when I enter a Form?

9.  Hacks / HackMaster
9.1.  What, briefly, is HackMaster / a Hack?
9.2.  How do I compile a free-standing code segment (Hack) with gcc? [***]

10.  General (not GNU SDK specific) Questions [+++]
10.1.  How do I tell my app to respond to a find? [+++]
10.2.  The second time I open a Database, I get the error:  "DataMgr.c,
       Line:4166 Err Getting Rec" [+++]

11.  IDEs, editors and such
11.1.  Emacs
11.2.  Visual SlickEdit
11.3.  PilotADE
11.4.  Microsoft Developer Studio
11.5.  VCP

12.  Copyrights and such

13.  Credits and contributors



                               T H E   F A Q


0.  Intro / About the FAQ


0.1.  Maintainer of the FAQ

Jeremy H. Sproat, e-mail at 


0.2.  Where can I find the FAQ on the Web?

I'll be posting this FAQ to the newsgroup pilot.programmer.gcc on
news.massena.com at around the first of each month.  Also, you can find it
at its home on the Web:
.  A Yahoo! search for "GNU Pilot SDK FAQ" will turn it up as well.  If
you send me an e-mail, I might be able to throw a copy your way.


0.3.  What is this FAQ all about?

This FAQ came about because I had so many questions that I didn't know
where to start, and browsing the newsgroups revealed about fifty others who
felt the same way I did.  So I stopped asking where the FAQ was and started
making one.

It is my intent to make this FAQ a quick reference to answer all those GNU
Pilot SDK questions that can't be or aren't answered in the documentation.
Even though my main area of experience in on the Win32 platform, I will
make every effort to make this FAQ as OS-balanced as possible.

This is in no way intended to replace the existing documentation.  If you
have a question that is answered *there*, then you shouldn't have to look
*here* for it.

Additionally, I will explicitly delete Pilot programming questions e-mailed
to me personally and expecting a personal repsonse.  If it's clearly in the
docs, you should read it there first.  If it's about changing the behavior
of programs in the SDK, take it up with those who manage the utilities.  If
it's a question that's best answered by people on the newsgroup, send it
there!


0.4.  What do the [+++] and [***] mean?

This is the method by which I mark questions that have been added [+++] or
changed [***] since the last posting to pilot.programmer.gcc.


0.5.  Where do you get the questions and answers for the FAQ?

I get a lot of them from questions that I have found answers to, a lot of
them from browsing the newsgroups pilot.programmer.gcc and
pilot.programmer, and a lot of them from Q&A that people submit to the FAQ.
It's about equal parts waiting for answers to find me and research.


0.6.  I've found a flaw in the FAQ / I want to submit a question or
      answer to the FAQ

E-mail me!  This FAQ will always need more Q&A.  Answers are favored over
questions, and answers with smallish code snippets are gold.  Additionally,
since I only have a Win32 box on my desk, any help you can give me for any
other platform would be greatly appreciated!

This is a living document.  It depends on you and others in the Internet
community in order to grow.


0.6.1.  What do the ##'s in the FAQ mean?

These are placeholders for myself.  They usually indicate places where I am
sure I need an answer, but I can't come up with one right away.  If you see
this and you have an answer, please e-mail me and let me know!


0.7.  So who is this Sproat guy, anyway?

Just this guy who decided to stop pulling out his hair and get organized.


0.7.1.  So he's an expert, right?

Not a chance.  Not yet, anyway.


0.8.  These questions and answers are way too simple for me.

That's because of two things:  First, my level of programming on the Pilot
right now is fairly low and many of these questions are based on problems
that I've had so far.  Second, I haven't received any Q&A that you can
really sink your teeth into.  Check back later (but please see the next
question!)


0.9.  This bites / I could do a better job on the FAQ

If you want to do better, let me know.  I don't mind passing on the torch
as long as the job still gets done.


0.10.  Tools used in writing the FAQ

My main production computer is a Microsoft Windows NT 4.0 workstation
patched with Service Pack 3.  I use Microsoft Word as it is shipped with
Microsoft Office 97 for the general layout.  The font is Courier New, 12
pitch.  The left and right margins are 0.5".  For code re-formatting, regex
search and replace functions, diff-ing, and other niceties, I use Visual
SlickEdit v2.0a.  This FAQ is posted to the Web and the newsgroup
pilot.programmer.gcc using Netscape Communicator v4.03.


1.  Stuff on the Internet


1.1.  Other FAQs and sources of information


1.1.1.  Pilot Software Development

Found at .  This is the
main jump-point for most Pilot developing on the Internet.  As well as
having links to just about every possible way to write code on the Pilot,
Darrin Massena has sponsored a very insightful set of articles by Luiz
Coutinho on the hardware inside the Pilot.  Bookmark this site at once.

As of January 1, 1998, Darrin Massena is no longer keeping this site the
most up-to-date source of Pilot developer information.  While this site is
still rich in information, he will point you to Wade Hatler's Pilot
Programming FAQ, RoadCoders.com, and his pilot.programming.* newsgroups for
more up-to-date information.


1.1.2.  PalmPilot Development Resources at RoadCoders

Found at .  The RoadCoders
site is dedicated to programming for palmtop computers.  Here, you will
find links to a large variety of SDKs for the PalmPilot, as well as all
sorts of source code, programming articles, and merchandise to help you on
your quest.


1.1.3.  Wade's Pilot Programming FAQ

Found at .  This is a
higher-level Pilot programming FAQ.  This is probably the best starting
point if you're not sure which SDK to use for your Pilot application.  This
FAQ is also available in German.


1.1.4.  The Responsive Knowledgebase for Developers

Found at .  This is a
knowledge base of Pilot programming issues.  Not large yet, but keep
checking back.  I think that this place has potential.


1.1.5.  The Pilot FAQ

Found at .  This isn't a programming FAQ, but
still a great document to browse for gerneral info about your Pilot and its
features. This FAQ is also available in Japanese.


1.1.6.  The Pilot developers' newsgroups at massena.com

Found at:






These are the Pilot developers' newsgroups.  They are generously hosted by
Darrin Massena.  I can get in just fine with Netscape Collabra, and I am
sure that most other news readers can access these newsgroups just as well.
This FAQ is posted on pilot.programmer.gcc, and many of the questions and
answers were taken from there.


1.2.  Other Pilot-related sites


1.2.1.  3Com/Palm Computing's PalmPilot Developer Zone

Found at .  This is the official
3Com page dedicated to developing for the Pilot.  This site has a definite
CodeWarrior slant.  I couldn't find any info for Palm OS1.

On the gripping hand, this is a good launchpoint for Pilot developers, and
the official source for the API documentation.


1.2.2.  Ray's PalmPilot Software Archive

Found at .  This is where I go for most
of my Pilot software needs.  It has a large, categorized index to all the
files here, and a list of the last 25 additions.  Each file available has a
description, a local copy, and a link to the original homepage.  Also,
there is a large development section with lots of code samples.  Good
stuff.


1.2.3.  C & PILA Source Code Page

Found at .  This
site holds all sorts of sources for Pilot programs written with gcc, PILA,
and CodeWarrior.  If you're just starting, you definitely should download a
couple and see how it's done.


2.  About the utilities


2.1.  gcc / prc-tools

GNU gcc is a very popular and free C/C++ compiler available for just about
any platform with more than 2 bits on the chip.  prc-tools was born when
gcc was ported by D. Jeff Dionne and Kresten Krab Thorup to cross-compile
for the Motorola 68328 Dragonball processor.  Various utilities in prc-
tools were done by Dionne and Ian Goldberg.  Dionne is the current
maintainer of prc-tools.  The current version of prc-tools is 0.5.0.,
corresponding to gcc version 2.7.2.2.  The official prc-tools archive with
Linux versions is at ; you'll
need the following GNU utilities at :
gcc-2.7.2.2, binutils-2.7, and gdb-4.16.  John J. Lehett has ported these
tools to Win32; you can find this version through .

As for the FAQ, all the UNIX-based FAQs seem to be out of date.  Check the
README in the prc-tools release first.  A generic gcc FAQ can be found at
.  A more Linux-oriented gcc
FAQ can be found at (##needs answer##).  A more Win32-oriented gcc FAQ can
be found at .  Full
documentation in html format for gcc, gdb, and make can also be found at
Andrew Howlett's site at
.

Note that gcc is GNU software, and the prc-tools package is a port of gcc.
The distinction is important; prc-tools is not maintained, distributed, or
handled in any way by the Free Software Foundation, Cygnus, or GNU.  In
this FAQ, the terms prc-tools and GNU Pilot SDK are used interchangably.


2.1.1.  gdb

gdb is GNU's general-purpose debugger.  It comes with the GNU Pilot SDK
distribution, and can debug programs sitting on Copilot and XCopilot.  It
was modified for use with prc-tools by Kenneth Albanowski and D. Jeff
Dionne.  On Linux, you can use gdb to debug programs on a real Pilot over
the wire.  I need to get the FAQ location for gdb.  Any takers?  (##needs
answer##)


2.1.2.  Copilot / XCopilot / Zilot

Copilot, XCopilot, and Zilot are excellent (and probably the only!) Pilot
emulators for Windows, X-Windows, and Macintosh, respectively.  The current
version of Copilot is 16h; however, the GNU Pilot SDK is distributed with
version 1.0 beta 9 which has been patched to work with gdb.  You can find
the Win32 version (Copilot), the XWindows version (XCopilot) and a lot of
documentation through .  Greg
Hewgill is the original developer for Copilot; Heath Hunnicut has since
taken over this task.  The changes to Copilot/XCopilot to work with gdb
were made by Ian Goldberg and D. Jeff Dionne.  Ben Thomas has a copy of
Copilot that works with gdb on Windows NT; it can be found at
.

Zilot is a Pilot emulator for the Macintosh, ported by Michel Pollet.  It
is available at .  It doesn't
appear to support the GNU Pilot SDK gdb stuff.  (##needs answer##)


2.2.  PilRC / PilRCUI

PilRC is what you use to compile your resource files into binary files to
link with your object code.  PilRCUI is a utility that comes with PilRC
which you can use to see how your GUI will look without needing to compile
the resource file.  Both utilities were written by Wes Cherry.  The current
version of PilRC is 2.0a.  You can find the Win32 version of these programs
through .
There is no FAQ available for PILRC, but it's really pretty straightforward
to use.


2.3.  Emacs

Emacs is a powerful, general-purpose text editor released under the GNU
Public License.  A trimmed-down version of Emacs is included with prc-
tools.  The current version of Emacs (as shipped with the Win32 GNU Pilot
SDK) is 19.34.1.  A generic FAQ for Emacs can be found at
.  A Win32-specific Emacs FAQ can
be found at .


3.  Install issues / Getting started


3.1.  How do I set up gcc in Linux or Windows 95/NT?

Right.  In general, before you read a FAQ, you should read the docs.  This
is one of those cases.  The install procedure is quite different between
the Linux and Win32 versions of gcc for Pilot.  You can find the directions
for setting up both the Linux and Win32 versions the end of the tutorial
that comes with the GNU Pilot SDK.


3.1.1.  Okay, so where do I find the tutorial / I deleted the tutorial

Reinstall and don't delete anything without backing it up first.  Having
said that, you can find Andrew Howlett's excellent GNU Pilot SDK tutorial
on his Web site at .


3.2.  I installed gcc to drive D: and now it doesn't work!

Put a \tmp directory on each hard drive.  Put a \bin directory on each hard
drive, and copy bash.exe into \bin as sh.exe.  (## Is there a more
streamlined way? ##)

From Derek Kwan:
One common problem is the path and environment doesn't setup correctly
using gcc for Windowz (either 95 or NT).  If gcc is installed on a drive
other than C:, it will not update the AUTOEXEC.BAT to setup the path and
enviorment.  Here is what you should check in your AUTOEXEC.BAT if nothing
works.  This example is assume you have install gcc on the D:\PROGRAM
FILES\GNU PALMPILOT directory

call d:\PROGRA~1\GNUPAL~1\bin\instsh.bat \bin
d:\PROGRA~1\GNUPAL~1\bin\bash.exe \bin\sh.exe
SET EMACSLOADPATH=d:\PROGRA~1\GNUPAL~1\emacs\lisp
SET EMACSPATH=d:\PROGRA~1\GNUPAL~1\bin
SET EMACSLOCKDIR=c:\temp
SET INFOPATH=d:\PROGRA~1\GNUPAL~1\emacs\info
SET EMACSDOC=d:\PROGRA~1\GNUPAL~1\emacs\etc
SET EMACSDATA=d:\PROGRA~1\GNUPAL~1\emacs\etc
SET gcc_EXEC_PREFIX=d:\PROGRA~1\GNUPAL~1\lib\gcc-lib\

Also make sure to include d:\PROGRA~1\GNUPAL~1\bin in your PATH.


3.3.  I can't get this to work in Win32S (Win 3.x) / DJGPP (DOS)!

That's because this is a true 32-bit app, and needs features that Win32S
and DJGPP lack, such as long filename support.  You really need a 32-bit OS
for this, but...

From D. Jeff Dionne:
It is possible to port these tools to DJGPP, but I've not done it for a
while (older versions once were).


3.4.  Can I / How do I set up gcc for developing for the Pilot on the
      Mac?

From D. Jeff Dionne:
For 68k mac, start with Stan Shebs gcc 2.3 (or some such) port of gcc to
Apple's MPW.  Use that to compile prc-tools (I've never done this, but Palm
has asked me if it can be done, and I've acquired some Mac hardware and
will make an attempt).


3.5.  Where can I find some source code to look at?

See the section about the "C & Pila Source Code Page".  Also, grab a copy
of some sample sources (including the Table object source code) from 3Com
at .

For beginner coders, Dave Kelly published source code for his Lottery
Checker, and gives some explanations and how-to's on his Web page at
.

From Frank Kannemann:
The *BEST* simple source code example:

The *BEST* complicated source code example is Launchpad it includes
multiple c sourefiles, lots of cool stuff:



3.6.  What is some good software to have on the side?

The Adobe Acrobat Reader is necessary for reading the PilotOS API docs from
3Com.

Perl comes in handy, especially if you're trying to write GLIBs or taking
advantage of Ian Goldberg's pilot-template utility (see next question).


3.7.  Is there a utility to take care of creating the basics for a new
      app?

Ian Goldberg has put together a perl script which will create a makefile,
main C file, etc. for you.  See his site at
, and look for pilot-template,
for more information.

Additionally, check out the utilities referred to in the section titled
"IDEs, editors and such".


3.8.  How do I get the rest of the Emacs distribution?

The Win32 version of the SDK comes with most of the Emacs files.  Missing
are the lisp source files, and files from the etc directory.  Fetch the
file  (without the line breaks).  In case you can't find this ftp
site right away...

From D. Jeff Dionne:
Search for 'ntEmacs' and 'washington' on Yahoo.


3.9.  I'm getting the error message "Error while dumping state
      (probably corrupt stack) in cygwin_except_handler" when I use the SDK!
      [+++]

This is on the Win32 platform only.  This error can be caused from a rogue
cygwin.dll from another Win32 GNU app.

From D. Jeff Dionne:
You likely still have the old cygwin.dll from 040 kicking around in the
path.  They are incompatible.


4.  Common pitfalls / Common questions / Not-so-common questions


4.1.  What are some of the most frequently-used command-line options
      for gcc?

OPTION       WHAT IT MEANS
======       =============
-c           compile only; don't link
-o ABC       output filename is "ABC"
-static      link static (not dynamic)
-OX          optimization level X (a number 1-5)
-g           build with debug symbols
-S           build to assembly


4.2.  Can I use the GNU Pilot SDK to compile program sources intended
      for CodeWarrior?

From D. Jeff Dionne:
gcc is now (as far as we know) fully compatable at the source code level
with CodeWarrior.  CodeWarrior UI resources are still a problem at this
time.


4.3.  What does the gcc error DISP16 mean? [***]

This is a linker error.  It means that you have called a function that does
not exist, or your code segment is too large.  Check your code for typos
first (especially the API calls, since they tend to be long.)

From Derek Kwan:
Most of the time when you have this error, you better check the CaSe of
your functions. For example if you call strstr as in regular C function you
will have this error. You have to use StrStr as in palmpilot developer
manual. For me everytime when I have a typo in the function which doesn't
exist or the CaSe of the function doesn't match, I will have this error. Of
course YMMV. :)

From Ian Goldberg:
The DISP16 error means that a (16-bit displacement) branch could not be
constructed, for one of two reasons:

1)  Branches cannot span more than 32K, so if you have more than that much
code, a refence to a symbol at the end of your code by something at the
beginning will give this error.  If you get a DISP16 for "bhook_start" or
something similar, this is the problem.

2) The symbol referenced simply does not exist.  This is the most common
reason for the DISP16 error.  Check to see if your function name is
misspelled or WronglyCapitalized.

From Robert Petersen:
Check that you aren't calling a function that is declared static from
another source file.  Static functions are only available in the source
file they are declared in, so the linker will act as if they don't exist
for code in separate modules.


4.3.1.  What does the gcc error DISP16 bzero mean? [+++]

From Ian Goldberg:
You have a structure or an array declared with a partial initailization,
like this:

void foo(void) {
    struct mystruct { int baz; ULong quux; } myvar = { 7 };
    /* or */
    int bar[6] = { 1, 2, 3 };
}

This is a known bug, but it's easy to work around: just complete the
initialization, or assign the values in code.


4.4.  I have a PilotMain() function, but the compiler says that I
      don't!

Make sure that your PilotMain() function is not declared static.

From Ian Goldberg:
There's no way your program will possibly link if it has a static
PilotMain.


4.5.  Why won't my global data work when I'm running a callback
      function?

From Ian Goldberg (reformatted):
Routines compiled by gcc, but called by routines _not_ compiled by gcc
(most commonly, your event handlers) have their globals sometimes broken,
unless you use a workaround.

At the top of the callback (right after the var. declarations), put

CALLBACK_PROLOGUE

At the bottom (just before the return), put

CALLBACK_EPILOGUE

Make _sure_ the event handler can _only_ exit by going through the
CALLBACK_EPILOGUE.

Also, do #include "callback.h" in your file.  callback.h is next.

---->8----cut here---->8----
#ifndef __CALLBACK_H__
#define __CALLBACK_H__

/* This is a workaround for a bug in the current version of gcc:
   gcc assumes that no one will touch %a4 after it is set up in crt0.o.
   This isn't true if a function is called as a callback by something
   that wasn't compiled by gcc (like FrmCloseAllForms()).  It may also
   not be true if it is used as a callback by something in a different
   shared library.
   We really want a function attribute "callback" which will insert this
   progloue and epilogoue automatically.
- Ian */

register void *reg_a4 asm("%a4");

#define CALLBACK_PROLOGUE \
   void *save_a4 = reg_a4; asm("move.l %%a5,%%a4; sub.l #edata,%%a4" : :);
#define CALLBACK_EPILOGUE reg_a4 = save_a4;

#endif
---->8----cut here---->8----


4.6.  Where can I get a generic makefile?

From Leo Breuss:
---->8----cut here---->8----
#Makefile for gcc PalmPilot crosscompiler m68k-palmos-coff-gcc package.
# Change the strings from APP to BUILDPRC to match your own
# system configuration.
# Place the file into the developping directory.
# Start it with "gmake".
# "gmake clean" removes all generated files, even the ".prc".
APP             =myownprogram
ICONTEXT        ="My Own"
ICON            =icon.bmp
APPID           =MyOn
RCP             =$(APP).rcp
PRC             =$(APP).prc
SRC             =$(APP).c
GRC             =$(APP).grc
BIN             =$(APP).bin

CC              =m68k-palmos-coff-gcc
PILRC           =pilrc
TXT2BITM        =txt2bitm
OBJRES          =m68k-palmos-coff-obj-res
BUILDPRC        =build-prc
BINDIR          =bin

# uncomment this if you want to build a gdb debuggable version
#DEFINES        =-DDEBUG
#INCLUDES =  -I ../PalmOS2 -I../PalmOS2/UI -I../PalmOS2/System
-I../PalmOS2/Hardware
#LINKFILES      =-l/usr/local/PalmPilot/m68k-palmos-coff/include/math.h
# LDFLAGS: including -g links gcrt0.o instead of crt0.o
#LDFLAGS         =
# -On: n=Optimization-level (0=none), -g: needed for debugging
CFLAGS          =-O0 -g $(DEFINES) $(INCLUDES)

all:            $(BINDIR) $(BINDIR)/$(PRC)

$(BINDIR): ;
mkdir $(BINDIR)

$(BINDIR)/$(PRC):       $(BINDIR)/grc.stamp $(BINDIR)/bin.stamp $(ICON);
$(shell cd $(BINDIR); $(BUILDPRC) ../$(PRC) $(ICONTEXT) $(APPID)
*.grc *.bin $(LINKFILES))
ls -l *.prc

$(BINDIR)/grc.stamp:    $(BINDIR)/$(APP) ;
$(shell cd $(BINDIR); $(OBJRES) $(APP))
touch $@

$(BINDIR)/$(APP):       $(BINDIR)/$(SRC:.c=.o) ;
$(CC) $(CFLAGS) $^ -o $@
cp $@ $(APP)

$(BINDIR)/bin.stamp:    $(RCP) ;
$(PILRC) $^ $(BINDIR)
touch $@

$(BINDIR)/%.o:  %.c ;
$(CC) $(CFLAGS) -c $< -o $@
#               touch $<
# enable this line if you want to compile EVERY time.

depend dep: ;
$(CC) -M $(SRC) > .dependencies

clean:
rm -rf *.o $(APP) *.bin *.grc *.prc $(BINDIR)/* *~
---->8----cut here---->8----


4.7.  Why has my makefile stopped working?

From Dave MacLeod:
Choose your editor carefully.  The makefile requires "hard tabs", i.e.
Chr(9).

Among the editors that support hard tabs are:  Emacs (comes with gcc for
Pilot), Visual SlickEdit, Microsoft Word, and others.  Check your editor's
documentation and/or look for ASCII character 0x09 in a hex dump of your
source code.


4.8.  I entered a few lines of code, and now I can't use the 'find'
      feature of my pilot without crashing!  a.k.a.  My program crashes the Pilot
      when I _install_ it!  What's going on?!

From Ian Goldberg:
You have code in PilotMain outside your cmd test.  PilotMain is called not
only when your program is launched, but in a number of other situations as
well (including when your program is installed, the user does a "Find",
etc.).  The first parameter to PilotMain is "cmd", a command code that
indicates under what circumstances the program was started.  Usually, you
only want to do things for a "Normal Launch"; that is, when (cmd ==
sysAppLaunchCmdNormalLaunch).  Note especially that for most of the launch
codes, _you have no global variables and any attempt to access them will
likely crash the Pilot_.

If you have any code outside the test for the value of cmd, you are almost
certainly doing the Wrong Thing.  The following PilotMain is, IMHO,
canonical:

DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
  Word err;
  if (cmd == sysAppLaunchCmdNormalLaunch) {
    err = StartApplication();
    if (err) return err;
    EventLoop();
    StopApplication();
  } else {
    return sysErrParamErr;
  }
  return 0;
}

The only reason you would need to change this is if you wanted to handle
different launch codes.


4.9.  What does "#pragma pack(2)" mean?

This is a holdover from prc-tools version 0.4.0 and earlier.

From Ian Goldberg:
Short answer: It does nothing, and can be removed.

Long answer: It sets the alignment for elements of structures to 2 bytes.
However, that's the default for m68k-palmos-coff-gcc, so it's unnecessary.


4.10.  How can I reduce the size of my .prc file? / Why has my .prc file
       size increased dramatically?

Try compiling with the gcc command-line switch -O2 (optimize) and remove
any -g switches (debugging symbols) when you link.

From Johnathan Vail:
Are you using floating-point or libc functions like printf()?  If you start
linking in standard C libraries you can bulk up an executable pretty
quickly.

From Ian Goldberg:
You should always compile with -g.  The debugging symbols don't get put
into the .prc file, so removing it won't make a difference in the size of
the .prc file (and you won't be able to debug your program).

Linking with the -g flag does add a very small amount of code to the .prc
file.


4.11.  My local variables are overwriting my global variables! / Is
       there a limit to the size of local variables?

From Ian Goldberg:
Is [your local variable] local or is it static?  Locals (automatics) go on
the (extremely small) stack.  Statics sit next to globals in memory.
There's no way a 5K object can be put on the stack (but gcc doesn't know
this; that's a _runtime_ decision).

If you are declaring your big array as:

  static int foo(int bar) {
    BigElement myarray[4];
  }

then change it to:

  static int foo(int bar) {
    static BigElement myarray[4];
  }

If you're already declaring it static, then you're probably writing off the
end of it, which would start into global variables.


5.  Copilot / XCopilot / gdb / Debugging


5.1.  How can I debug with Copilot / XCopilot and gdb?

1)   First of all, you need TCP/IP on your computer.  (If you can go over
the Internet, you have TCP/IP.)

2)   Compile your program with -g (debug symbols).  Don't delete the .o
files after compiling, as these contain the actual debug symbols.

3)   Start m68k-palmos-coff-gdb with the name of your program (without the
.prc extension) as an argument.

4)   Launch Copilot or XCopilot with the argument "-gdebug :2000" (make
sure that there is a space between the "g" and the ":"!)

5)   From the gdb prompt, give the command "target pilot ", where
"" depends on where your code is running.  If you're using Copilot,
it's "localhost:2000".  For XCopilot, "/dev/ttyqf".  If you're debugging on
a real Pilot from Linux, try "/dev/pilot" or "/dev/ttyS0" or whatever port
your Pilot is using.

6)   Before you enter the program you are debugging, be sure to load
gdbpanel.prc into Copilot/XCopilot and mark the checkbox "Enable stub"
inside this app.  (You can find this file in the "example" subdirectory.)
7)   Be sure to reload the program you are debugging.  Launch your program.
gdb should break on PilotMain().

5.1.1.  I don't have an "example" directory / I can't find gdbpanel.prc!

Reinstall the GNU Pilot SDK, this time installing the examples.


5.2.  I'll just use Copilot / XCopilot to debug, thanks.

From D. Jeff Dionne:
XCopilot has no built in debugger, it relies solely on gdb, where CoPilot
has a built in debugger that knows about MetroWerks debug symbols.

If the standard Copilot debugging is enough for you, you can compile with
[gcc option] -mdebug-labels and you code will contain the same sort of
wasteful strings and such as the other tools generate.  This feature was
added by Kresten a while ago to make Copilot's debugger happy.


5.3.  How can I debug my program in Copilot on Windows NT?

You can't, at least with the Copilot that is distributed with prc-tools.
When you try running it, you will get an error message saying that your
executable is not a valid NT image.

Ben Thomas has built Copilot so that it will work with gdb on Windows NT.
D. Jeff Dionne is working with him to include the fix in the next release
of prc-tools.  For now, it can be obtained from



5.4.  I downloaded Copilot / XCopilot from its original Web site, but I
      can't get it to debug with gdb!

Right now, the only version of Copilot and XCopilot that will work with gdb
is that which comes with prc-tools.


5.5.  The lines in gdb don't match up with what my program's doing!

This seems to be happen only on Windows 95/NT.  Your extra end-of-line
character is throwing off the debugger.  Save your source files in Unix
format (end-of-line = 0x0A instead of 0x0D0A), recompile, and try again.

From Ben Thomas:
Line number problems can also occur if you are out of sync between source
and binary.  Surprisingly simple, but it happens.  Just rebuild to cure.


5.6.  I'm debugging and I can't see all of my variables!

From D. Jeff Dionne:
If you've specified any optimization level ( a -O command line switch ) to
gcc, it may have optimized away those vars.  Try building again without any
-O switches and see how that goes.


5.7.  Why can't I edit database records in-place while I'm debugging?

From Yves Mahe:

The PalmPilot databases are write protected (see documentation for
DmWrite).  Old versions of Copilot used to allow it, but new versions catch
this error that will generate a Fatal Error on the PalmPilot. The only way
to modify a database record is to use DmWrite or DmSet.


5.8.  How do I compile a breakpoint into my code?

You may not need to.  gdb should break on PilotMain(), and will allow you
to set breakpoints from there.  Here are a couple more suggestions:

From Yves Mahe:
Put the following in your C code:
asm( "dc.w 0x4afc"); for breakpoint
And the debugger will be launched by Copilot automatically.

From D. Jeff Dionne:
Try DbgBreak()  It's defined in System/DebugMgr.h, but for the CoPilot
debugger only, which we ripped out of XCopilot.


6.  API / Libraries


6.1.  What APIs are available?

There is the standard API from 3Com.  The most recent version is for Palm
OS2.  As well as additional API calls, there are some calls that have
changed from Palm OS1.  See the documentation available from 3Com for more
details.

The HackMaster utility from DaggerWare has an API you can use to create
system-level control panel-like utilities.  See the section on HackMaster
for more information.

PilRC 2.0 introduced the capibility to create, manage, and generally play
with 2-bits-per-pixel greyscale bitmaps.  Wes Cherry has devised an API
called Win2 to handle this.  For more information, please see
.


6.1.1.  Can I use the standard C libraries?

From D. Jeff Dionne:
prc-tools comes with a minimal libc that contains string functions,
(s)printf and such.  Also comes with a single precision math library that
can be used on PalmOS1 or 2.  libc can be used shared or static.


6.1.1.1.  What does the Copilot error "palmos_GLib.c, Line:23, C Library is
          not installed" mean?

From D. Jeff Dionne:
You've used a function from libc (printf, whatever) and you're linked
dynamic, which is the default.  When your code calls this function, it
tries to auto load the shared version of libc.  If you load Libc.prc
into your Pilot, it will find it at run time, or you can specify -static
when you link. That will link libc.a into your code insted of linking
with the shared version.


6.1.1.2.  The  functions aren't working!

That's because you're linking the standard C library dynamically.

From Paul McDermott:
If you look in , you'll see that isalpha() is defined as a macro
which looks up values in a global array _ctype[]. When the shared library
is created, this array becomes global for the shared library, not for your
application. So when isalpha(c) is converted to ((_ctype+1)[c]&(_U|_L)),
_ctype is pointing somewhere invalid, and you get crazy results.

 functions should work if you link libc as static.  The problem
described above will only occur if if you create a libc shared standard C
library.


6.1.2.  I can compile C++!  Is there a class library for the Pilot?

Yes there is.  It's called PCL, and it's being developed by Thomas Johler.
You can find it along with more information on compiling C++ for the Pilot
at .


6.1.2.1.  I *can't* compile C++!  Where can I find information on getting
          this to work? [+++]

(##needs answer##)


6.2.  What's this business about shared libraries?

Ian Goldberg has detailed the necessary steps to creating a GLIB shared
library.  Please see his site at
.

From Ian Goldberg:
Shared libraries enable many applications to share common code, without
having to have a copy of the code in each application's code resource. For
example, there can be one copy of encryption routines, or a version of the
standard C library, and many applications can be using it.

Shared libraries can also help you get around the 32K code size limit; you
can break up your code into a main portion (of at most 32K), and a number
of libraries (each of at most 32K).

GLib (pronounced ``gee-lib'') shared libraries are a way to implement
shared libraries on the Pilot that differs from the ``standard'' (SysLib)
mechanism for the Palm Pilot.

From D. Jeff Dionne:
You will need Perl and a few other UNIX goodies to make these work on
Windows until I get around to creating versions of the tools required in C.


6.2.1.  How can my app tell if a shared library is loaded on the Pilot?

From D. Jeff Dionne:
Just try opening the lib's code resource by type and creator.  If it fails,
it ain't there.

From Ian Goldberg:
...and if it _doesn't_ fail, make sure to close it again, or its refcount
will be too high.


6.3.  What's this business about dynamically creating your GUI?

Gary T. Desrosiers wrote an in-depth article with examples on how to create
your GUI from inside your program without the need for a resource file.
Please see his site at .


6.4.  Can I use lex/yacc (or flex/byacc/bison etc.) in my Pilot
      program?

From D. Jeff Dionne:
Flex and Bison make code with a large footprint.  byacc will produce
something usable, but you'll likely need to put it in a shared lib and
build your own lexer.  One more complication, even byacc will use enough
stack to cause you trouble unless you increase the default size. After
that, you'll be fine.


7.  Pilot Memory / Databases


7.1.  What, briefly, is a Database?

A Database is an abstraction of a file on the Pilot.  It sits in RAM along
with everything else, but is accessable through a special Database API.
Please see the documentation from 3Com for more details.


7.2.  What happened to malloc() / realloc() / calloc() / free()?

These functions are part of the ANSI C library (see the question concerning
the standard C libraries) and technically are not required for C
programming.  You can use MemPtrNew() and MemPtrFree() to replace malloc()
and free(), respectively.


7.3.  What's this about a 32k limit? / How do I get around the 32k
      limit? [***]

Because the largest possible dynamic heap is 32k bytes long, there is a
similiar limit on the size of memory chunks.  You could try to reclaim some
space by optimizing your compile; use the gcc option -O2.  Another solution
to this problem is to use shared libraries.  See the question about shared
libraries for more information.

Note that there are other memory restrictions; for example, Databases are
limited to 64k, and the stack can only be 4k.

From Peter Webb:
The limitations that I know about are:

1)  No program code segment bigger than 32k
2)  No more than 32k memory dynamically allocated at any one time
3)  No file larger than 64k
4)  Applications + Data <= Installed memory (usually 1Mb, upgradable to 3Mb
and maybe higher via various third parties).

However, you can get around the 32k limit by using shared libraries (which
both gcc and CodeWarrior 4 support), and the 64k limit by using Pilot
Databases cleverly. For example the "Doc" application splits its "books"
into multiple Databases, and seamlessly jumps from one to the next, as
necessary. You can do the same.

From Alan Jay Weiner: [***]
Databases are not limited to 64k though - although the *records* within
them are.

Code segments may be up to 64k, but since code references are 16-bits once
you get over 32k you may get link errors.  Then you get into games like
changing the link order so everything's within 32k of any callers - truly a
pain...


7.3.1.  How can I find out how much code and data there is in my object
        file?

From Ian Goldberg:
Try "m68k-palmos-coff-objdump --section-head *.o".  This will show the
amount of code and data each .o file contains.


7.3.2.  Can I use a Database to simulate large memory chunks?

Yes you can.  Take a look at the source code for Wes Cherry's 2-bits-per-
pixel bitmap utilities at
.  The function
_Win2DoAllocScreen() in the file win2.c uses the API function
MemSemaphoreReserve() to accomplish this trick.


7.4.  How do I read a Database from, say, Memopad?

From D. Jeff Dionne:
You'll need to have a look in the pilot-link package for the structure of
those databases.  Then just open then by type and creator.


7.5.  Can I create a Database (.pdb file) from my PC instead of using
      my Pilot?

Yes you can.  Several people have documented the .pdb file format.  You
might also want to look at a couple of programs that will generate a .pdb
file for you.  While they are not officially a part of the prc-tools
distribution, they may serve the function you need.

Ken Shirriff's utility builds a .pdb file from files you supply; his
utility can be found at
.  Tim Delaney's PDB
Compiler generates a .pdb file from a script you supply; his utility can be
found at  and uses Ken
Shirriff's program.  Note that both programs are written in Java.


8.  Pilot Resources


8.1.  What, briefly, is a resource?

A resource is a special Database that is associated with your program.  It
contains information about your GUI and other things, such as strings.
Please see the documentation from 3Com for more details.


8.2.  Can I create resources without using PilRC?

Yes you can.  See the question labelled "What's this business about
dynamically creating your GUI?"


8.3.  Can I mask field input to numbers like I can with CodeWarrior?
      [***]

Not the way CodeWarrior does it, no.  The most recent version of PilRC
includes some (currently broken) support for a "NUMERIC" field, but it
seems that there's not much support from the Palm OS.

From Chris Pratt:
Process the keyDownEvent and check the current field.  If it should only
accept numbers, check event->data.keyDown.chr; if it's between '0' and '9',
return false, otherwise return true.

From Daniel McCarty:
As was later noted in that thread, you also have to watch for pastes and
other things, too.  It ends up being better (imo) to run the check when the
form is closing (if it's a dialog form) or some other type of just-in-time
validation.


8.4.  How do I dynamically add data to a List?

From Phil Mayes (edited):
I construct a list on the fly:

char* array[SEATMAX];
int i;
for (i = 0; i < SEATMAX; i++)
  array[i] = GetPlayerIndexName(pPlan->m_Seat[i]);
LstSetListChoices(pList, &array[0], SEATMAX);
// start at 4th item
LstSetTopItem(pList, 4);
TblGetItemBounds(pTable,wRow,wCol,&rectBounds);
LstSetPosition(pList, rectBounds.topLeft.x, rectBounds.topLeft.y);
wIndex = LstPopupList(pList);


8.5.  I'm having trouble with Table.

Join the club.  :-,  Seriously, Wes Cherry's PilRC has some example code
setting up a Table.  To see what's going on in the background, you should
take a look at 3Com's source code for the Table object; see the question
titled "Where can I find some source code to look at?"  Also, be aware that
you will need to take advantage of Ian Goldberg's callback fix; see the
question titled "Why won't my global data work when I'm running a callback
function?"

From Daniel McCarty:
The source to Fitness was recently released at
.  It makes extensive use of
tables.


8.6.  How do I create a Gadget?

(##needs answer##)  Roger Flores has posted a method to implement a button
with a bitmap.

From Roger Flores:
Just create a button with no text in it where you want and then place a
tFBM with a picture in it at the same location.  The graphic will appear to
be drawn by the button.  Touching the button will invert the graphic
properly.

For an example of how this looks, look at the "graphic buttons" in the
HotSync app.


8.7.  How do I force a Field to have focus when I enter a Form?

From Bozidar Benc:
Here is a piece of code from my form event handler.  I also set upper shift
to true if the field is empty.

  case frmOpenEvent:
    frm = FrmGetActiveForm();
    fldIndex = FrmGetObjectIndex(frm, myFieldID);
    FrmDrawForm(frm);
    FrmSetFocus(frm, fldIndex);
    if (!FldGetTextLength(FrmGetObjectPtr(frm,fldIndex)))
      GrfSetState (false, false, true);
    handled = true;
    break;


9.  Hacks / HackMaster


9.1.  What, briefly, is HackMaster / a Hack?

Essentially, a Hack is a special program that handles system-level Traps.
This allows you to write an incredibly versatile set of control panel-like
utilities to change the behavior of the Pilot.  HackMaster is a utility
from DaggerWare for managing Hacks on your Pilot.  For more information on
Hacks and HackMaster, as well as a Hack FAQ and API reference, see the
HackMaster site at .


9.2.  How do I compile a free-standing code segment (Hack) with gcc?
      [***]

From Douglas Beal:
Use the flag -nostartfiles

From D. Jeff Dionne:
It is difficult right now to make HackMaster hacks with gcc - your mileage
may vary.

From Daniel McCarty:
It is possible to use gcc to build Hackmaster extensions. The hard part is
not with gcc, but rather getting the code generated by gcc to have the
correct code resource ID for Hackmaster. That is where pila comes in. [I
think pila is actually part of the ASDK.]

First, I build a prc using the gcc tool set as if my Hackmaster extension
was really an application. I am sure to put my trap handler FIRST in the
source file, and the object file resulting from that source file appears
FIRST on the link line. One other minor difference is that I include -
nostartfiles on the link line because I don't have a PilotMain(), so I
don't need crt.o.

m68k-palmos-coff-gcc -O2 -g -nostartfiles MyTrapHandler.c -o MyTrapHandler
m68k-palmos-coff-obj-res MyTrapHandler
build-prc MyTrapHandler.prc FakeApp Fake code0001.MyTrapHandler.grc

To extract the code 1 resource from the generated prc I use prc2bin, and
then I rename code0001.bin to something more palettable, like
MyTrapHandler.bin

prc2bin MyTrapHandler.prc
mv code0001.bin MyTrapHandler.bin

Any other resources my Hackmaster extension needs are built with pilrc.  If
you include an "About" form in your hack, there would be a file
tFRM0bb8.bin. If you include a control panel, there would be a file
tFRM07d0.bin. [See below for more on control panels.]

Now I want to get MyTrapHandler.bin into my HACK type prc. This prc will
contain all the UI resources, Info panel and Control panel for my hack. The
best (== none of my money, none of my time) way I've found to do this is to
use pila to suck in the object, and give it the Hackmaster trap handler
code ID 1000 with a line like:

res 'code', 1000, "MyTrapHandler.bin"

Similarly, I include the other resources my hack requires. I used the asm
file included in the Hackmaster example AlrmHack as a template. For my
"About" form I include the line:

res 'tFRM', 3000, "tFRM0bb8.bin"

Then I run pila on my file HackMain.asm and then test the resulting
HackMain.prc file.

pila -t "HACK" HackMain.asm

* * * NOTE about Control panels:
Like the trap handler itself, the control panel handler must also reside in
a specific code resource, one with ID 2000. So for Control panel handlers,
I build a bin file exactly as I had built the trap handler bin file and
include one more line in my HackMain.asm file.

res 'code', 2000, "MyTrapController.bin"

One of the (big) limitations of this method is that the code in
MyTrapController cannot call code in MyTrapHandler, because they are linked
separately. In practice, I haven't found this to be a major headache
because control panels usually don't require a huge library of behavior.

Here's what I see when I build using this method. [The source files are
MyTrapHandler.c, MyTrapController.c, HackMain.asm and the output file is
HackMain.prc]

m68k-palmos-coff-gcc -O2 -g -nostartfiles MyTrapHandler.c -o MyTrapHandler
m68k-palmos-coff-obj-res MyTrapHandler
build-prc MyTrapHandler.prc FakeApp Fake code0001.MyTrapHandler.grc
prc2bin MyTrapHandler.prc
mv code0001.bin MyTrapHandler.bin
Writing MyTrapHandler.hdr, length 78, from offset 0x0
Writing code0001.bin, length 1272, from offset 0x5a
1 resources plus header written!
m68k-palmos-coff-gcc -O2 -g -nostartfiles MyTrapController.c -o
MyTrapController
m68k-palmos-coff-obj-res MyTrapController
build-prc MyTrapController.prc FakeApp Fake code0001.MyTrapController.grc
prc2bin MyTrapController.prc
mv code0001.bin MyTrapController.bin
Writing MyTrapController.hdr, length 78, from offset 0x0
Writing code0001.bin, length 80, from offset 0x5a
1 resources plus header written!
pilrc MyTrapHandler.rcp
pilrc v1.5.  by Wes Cherry (wesc@ricochet.net)

Writing ./tFRM0bb8.bin
435 bytes
Writing ./tFRM07d0.bin
267 bytes
pila -t "HACK" HackMain.asm
Pila 1.0 Beta 3

Code: 8 bytes
Data: 4 bytes (43 compressed)
Res:  2139 bytes
PRC:  2308 bytes
0 errors, 0 warnings

From Bozidar Benc:
Here is how my MAKE.BAT looks like:

---->8----cut here---->8----
pilrc dshack.rcp
d:\programs\gcc\bin\m68k-palmos-coff-gcc -O2 -g -nostartfiles dstrap.c -o
dstrap
d:\programs\gcc\bin\m68k-palmos-coff-obj-res dstrap
d:\programs\gcc\bin\build-prc dstrap.prc FakeApp Fake code0001.dstrap.grc
prc2bin dstrap.prc
mv code0001.bin dstrap.bin
pila -t "HACK" dshack.asm
del *.bin
del *.grc
del *.hdr
del dstrap
del dstrap.prc
---->8----cut here---->8----


10.  General (not GNU SDK specific) Questions [+++]


10.1.  How do I tell my app to respond to a find? [+++]

From Alan Macy:
You need to handle the sysAppLaunchCmdFind command in your PilotMain
function, as shown here.  Also note the sysAppLaunchCmdGoTo:

---->8----cut here---->8----
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
  Word error = RomVersionCompatible (version20, launchFlags);
  if (error)
    return error;
  switch (cmd) {
    case sysAppLaunchCmdNormalLaunch:
      PrefGetPreferences(&SysPrefs);
      StartApplication();
      EventLoop();
      StopApplication();
      break;
    case sysAppLaunchCmdFind:
      Search ((FindParamsPtr)cmdPBP);
      break;
    case sysAppLaunchCmdGoTo:
      if (launchFlags & sysAppLaunchFlagNewGlobals) {
        PrefGetPreferences(&SysPrefs);
        StartApplication ();
        GoToRecord ((GoToParamsPtr) cmdPBP, true);
        EventLoop ();
        StopApplication ();
      } else
        GoToRecord ((GoToParamsPtr) cmdPBP, FALSE);
      break;
    case sysAppLaunchCmdSaveData:
      break;
    case sysAppLaunchCmdSyncNotify:
      HandleHotSync();
      break;
  }
  return 0;
}
---->8----cut here---->8----


10.2.  The second time I open a Database, I get the error:  "DataMgr.c,
       Line:4166 Err Getting Rec" [+++]

This can happen if you don't release the Database records you used.  For



11.  IDEs, editors and such


11.1.  Emacs

Emacs is an extremely powerful text editor that comes with the GNU Pilot
SDK.  It features syntax highlighting and built-in debugger support.  After
the learning curve, it offers the best IDE solution.


11.2.  Visual SlickEdit

Visual SlickEdit is another powerful text editor that has many of the
features of Emacs except the built-in debugger interface.  It supports
projects, procedure tagging, syntax highlighting, and emulation of some of
the most popular editors.  This is what I use.  Check out a demo at
.  It's really cool, amazingly configurable,
really powerful, kinda expensive, and has completely won me over.  `Nuff
said.


11.3.  PilotADE

PilotADE was written in Microsoft Visual Basic 5 by Dr. James Hallows and
Edward D. Omiccioli, Jr.

From the Web site:
PilotADE is basically a text editor with a few additional features to help
in writing applications for the Pilot.  PilotADE was originaly written by
Dr. James Hallows in Visual Basic 4.  It is a front end for both the ASDK
and gcc.  He wanted a decent text editor that would avoid having to use
multiple notepads, several DOS windows, constant referral back to
Explorer/File Manager etc without the need to buy expensive commercial
software.

You can find PilotADE at
.


11.4.  Microsoft Developer Studio

There are rumors that you can get the GNU Pilot SDK to work from inside the
MSDS.  Aside from using Microsoft's NMAKE instead of GNU make, I have no
idea how this is done.  For what it's worth, I've also heard rumors that
all the Vorlons have passed beyond the Rim.  You know how rumors go.

From Wes Cherry:
Darrin Massena hacked together some tools to allow Microsoft's Visual C 68k
cross compiler generate pilot programs (without gcc).  He never really
polished the effort because Microsoft still charges around $1K for the
compiler...

As for making Visual C work w/ gcc, you can import a gcc project makefile
(File/Open/Workspace).  You'll also have to configure
Tools/Options/Directories/Executable to point to your gcc bin dir.  Change
the project settings to invoke make instead of nmake.

gcc emits errors in a different format than Microsoft compilers so F4 for
next error won't work.

I suppose you could define custom build rules, rather than wrapping an
existing makefile, but that'd be a pain.


11.5.  VCP

VCP is a freeware program written in Microsoft Visual Basic by Joerg Grohne
which, among other things, provides a GUI through which you can build your
Pilot application's user interface.  The current version of VCP is 0.95.
Please note that this is a beta release.  You can find VCP at


From the Web site:
VCP is used to develop applications for the usr palm pilot. VCP should
offer the same comfort as Visual C or Visual Basic does. That means laying
out the screen of an application using drag and drop, editing the event
procedures of objects by clicking on them etc.


12.  Copyrights and such

Pilot, PalmPilot, PalmSoft, and other 3Com-owned stuff is copyright 3Com.

GNU and GNU utilities are copyright the Free Software Foundation.

Utilities included in prc-tools are copyright D. Jeff Dionne, Kresten Krab
Thorup, Kenneth Albanowski, Ian Goldberg, and others.  Most are freeware
under the GNU Public License.

PilRC is copyright Wes Cherry.

Linux is copyright Linus Torvalds.

PilotADE is copyright Dr. James Hallows.

HackMaster is copyright DaggerWare.

RoadCoders is copyright Iain Barclay.

CodeWarrior is copyright Metrowerks.

Visual SlickEdit is copyright MicroEdge, Inc.

VCP is copyright Joerg Grohne.

Acrobat Reader is copyright Adobe, Inc.

Vorlons are copyright J. Michael Straczynski and may also be claimed by
Warner Brothers Studios and other radical Earther groups.  May they (the
Vorlons) forever stay on the other side of the Rim.

Microsoft Windows 95, Microsoft Windows NT, Microsoft Word, Microsoft
Office 97, Microsoft Developer Studio and its utilities, Microsoft Visual
Basic, and other Microsoft Stuff is copyright Microsoft.

All other copyrights are still copyright their respective owners, I just
haven't been able to figure out who's whose.  If you have found an error in
this list, please e-mail me immediately at .  If you
would like more copyright information, please contact me or the respective
copyright holders.


13.  Credits and contributors

There is no way I could have even gotten this FAQ off the ground without
the work, postings, directions, criticism, or help from the following
people:

            3Com and PalmSoft 
                   Andrew Ball (e-mail address witheld)
                   Andrew Howlett 
                       Ben Thomas 
                Bharat Mediratta 
            Blake Winton 
                   Bozidar Benc 
                Brett Wuth 
                     Bruce Barrett 
                    Charles Andrews 
                     Chris Pratt 
                      D. Jeff Dionne 
                DaggerWare 
               Daniel McCarty 
                    Darrin Massena 
                   Dave Kelly 
                   Dave MacLeod 
                      Derek Kwan 
                 Douglas Beal 
                Dr. James Hallows 
           Edward A. Ranzenbach, PA-C 
               Edward D. Omiccioli, Jr. 
          Free Software Foundation, The 
                 Frank Kannemann 
                  Gary T. Desrosiers 
                    Greg Hewgill 
                  Heath Hunnicutt 
                   Iain Barclay 
                    Ian Goldberg 
                     Joe Sacher 
                Joerg Grohne <### need e-mail address ###>
                          John 
                  John Higgins 
                     John J. Lehett 
                   John McDonald 
               Johnathan Vail 
                     Ken Corey 
                    Ken Shirriff 
                  Kenneth Albanowski 
                  Kresten Krab Thorup 
                   Leo Breuss 
                   Luiz Coutinho 
                      Michel Pollet 
                Mike McCollister 
                     Morris Jones 
                    Paul Dugas (e-mail address witheld)
                    Paul McDermott 
                      Phil Mayes 
                     Peter Webb 
    Responsive Software 
                 Richard Bradshaw 
                 Robert Petersen 
                       Roger Flores 
                    Roman Baker 
        Ryerson Amateur Radio Club, The 
                 Scott A. Krieger 
                   Stephen Waits 
                    Steve Wallace 
                      Thomas Johler 
                     Todd Breiholz 
                      Wes Cherry 
               Yves Mahe 

Thank you all for your help!

Cheers,
  Jeremy H. Sproat
  jsproat@geocities.com

    Source: geocities.com/siliconvalley/horizon/5249

               ( geocities.com/siliconvalley/horizon)                   ( geocities.com/siliconvalley)