Code

All the code for the book is available here.

Tutorial chapter

The contents of Chapter 4, a tutorial on creating a simple Palm OS application are online in order to keep them up-to-date with changes to the development environments and SDKs.

Errors

May 2, 2002

There's a bug in the DLL shim code on page 479. The current code looks like:

#define DeclareCMShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gCondMgrLib)

#define DeclareHSShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gHsapiLib)

#define DeclareIAShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gCondMgrLib)
It should be:
#define DeclareCMShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gCondMgrLib)

#define DeclareHSShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gHsapiLib)

#define DeclareIAShimFunction(returnResult, name, apiDecl, apiCall) \
    DeclareShimFunction(returnResult, name, apiDecl, apiCall, gInstAideLib)

January 10, 2002

The statement in Chapter 1 that no Palm device would have a keyboard wasn't a good forecast. It turns out that Handspring has announced the Treo 180, which comes in two versions: the Treo 180, which includes a small keyboard, and the Treo 180g, which comes with the traditional Grafitti input area.

Chapter 9, page 252 describes FrmGetObjectID. Unfortunately, that's capitalized wrong. It should be FrmGetObjectId. The entry for that function in the index (on page 669) has the same wrong capitalization.

Chapter 14, Example 14-2 is missing the declaration of err:

#include <Windows.h>
#include "CondMgr.h"
#include <stdio.h>

int main(int argc,char **argv)
{
  const char *kCreator ="SLES";
  int err;

  err = CmInstallCreator(kCreator, CONDUIT_APPLICATION);
  if (err == 0)
    err = CmSetCreatorName(kCreator, "C:\\Sales\\Debug\\Sales.DLL");
  if (err == 0)
    err = CmSetCreatorDirectory(kCreator, "Sales");
  if (err == 0)
    err = CmSetCreatorFile(kCreator, "Sales");
  if (err == 0)
    err = CmSetCreatorPriority(kCreator, 2);
  if (err == 0)
    printf("Registration succeeded \n");
  else
    printf("Registration failed %d \n",err);
  return err;
}

Chapter 14, Example 14-3 has a couple of problems (missing include file, a missing return, and the creator should be all-caps). Here's the correct version:

#include <Windows.h>
#include <CondMgr.h>
#include <stdio.h>

int main(int argc,char **argv)
{
  const char *kCreator ="SLES";
  int numConduitsRemoved = CmRemoveConduitByCreatorID(kCreator);
  if (numConduitsRemoved >= 0)
    printf("Unregistration succeeded for %d conduits \n", numConduitsRemoved);
  else
    printf("Unregistration failed %d \n", numConduitsRemoved);
  return 0;
}

Chapter 14, Example 14-6 misspells two calls, inverts the check of PalmDLLShimInit (and misses a declaration of err):

#include <Windows.h>
#include "CondMgr.h"
#include <stdio.h>
#include "PalmDLLShim.h"

int main(int argc,char **argv)
{
  const char *kCreator ="SLES";
  int err;

  if (!PalmDLLShimInit("C:\\PalmDLLs")){
    fprintf(stderr,"Initialization failed \n");
    exit(1);
  } 
  err = CmInstallCreator(kCreator, CONDUIT_APPLICATION);
  if (err == 0)
    err = CmSetCreatorName(kCreator, "C:\\Sales\\Debug\\Sales.DLL");
  if (err == 0)
    err = CmSetCreatorDirectory(kCreator, "Sales");
  if (err == 0)
    err = CmSetCreatorFile(kCreator, "Sales");
  if (err == 0)
    err = CmSetCreatorPriority(kCreator, 2);
  PalmDLLShimDeinit();
  if (err == 0)
    printf("Registration succeeded \n");
  else
    printf("Registration failed %d \n",err);
  return err;
}

Example 14-7 returns true even if the libraries couldn't be loaded. Here's the fix:

if (!gCondMgrLib ||!gHsapiLib ||!gInstAideLib){
	if (gCondMgrLib)
	FreeLibrary(gCondMgrLib);
	gCondMgrLib =NULL;
	if (gHsapiLib)
		FreeLibrary(gHsapiLib);
	gHsapiLib =NULL;
	if (gInstAideLib)
		FreeLibrary(gInstAideLib);
	gInstAideLib =NULL;
	return false;
}

History

December, 1998

First edition published in December, 1998. This was the first Palm OS programming book published, and was written before Palm OS source code was available, and when the Palm documentation was in a less complete state than it is now. It used the Palm OS 3.0 APIs.

January-September, 2001

The book was completely rewritten using the 4.0 SDK. It is much more accessible to newcomers--features include a complete tutorial on installing your choice of SDK.

October 9, 2001

The book went to the printers on October 9, 2001 and should be available from your favorite bookstore towards the end of October.

October 25, 2001

The book is now available from O'Reilly, Amazon, and your favorite bookstore.

November 15, 2001

Updated all Mac samples to fix file-types (my script wasn't setting the files to be TEXT, which bothered CodeWarrior immensely).

January 9, 2001

Updated OReilly Stationery to use 4.0 SDK (since CodeWarrior 8 only ships with 4.0 SDK).

 

[Calliope Home]