I am new at this. I thought it would be fun to learn to write programs for
the Palm Pilot. I am trying to teach myself using a book (The Palm
Programming Developer's Guide by Neil Rhodes). I started by writing a
simple program to retrieve the Palm OS version number. I already have a
problem.
The program uses FtrGet to acquire the OS Version and StrIToH to convert it
to a printable format. It then uses a custom alert to show the version
number. I use GCC for Palm and PilRC and the program compiles fine. It
also runs with no problem using POSE. But when I Hotsynch the program down
to the pilot, the version number is blank and I get a "beep" which I think
indicates a problem. No error message, etc. is shown. Also, sometimes it
seems that when I download a new version of the program to the palm, I
still get the old version. (Even when I delete it.)
Has anybody encountered the same problem? I will attach my .c module and
the .rcp file. I am truly stumped. I would greatly appreciate any help
/*
CBUPalm.c
For Palm Pilot access to the Check Book Utility
by Ken Whitehead
*/
#include <Pilot.h>
#include "CBUPalm.h"
#ifdef __GNUC__
#include "Callbacks.h"
#endif
// for definition of IsDigit
#include <CharAttr.h>
#include <SysEvtMgr.h>
static int StartApplication(void);
static void StopApplication(void);
static void EventLoop(void);
static Boolean ApplicationHandleEvent(EventPtr event);
static Boolean CBUFormHandleEvent(EventPtr event);
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
Err err = 0;
if (cmd == sysAppLaunchCmdNormalLaunch)
{
if ((err = StartApplication()) == 0)
{
EventLoop();
StopApplication();
}
}
return err;
}
static int StartApplication(void)
{
FrmGotoForm(CBUPalmForm);
return 0;
}
static void StopApplication(void)
{
}
static void EventLoop(void)
{
EventType event;
Word error;
do {
EvtGetEvent(&event, evtWaitForever);
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! ApplicationHandleEvent(&event))
FrmDispatchEvent(&event) ;
} while (event.eType != appStopEvent) ;
}
static Boolean ApplicationHandleEvent(EventPtr event)
{
FormPtr frm;
Int formId;
Boolean handled = false;
if (event->eType == frmLoadEvent)
{
// Load the form resource specified in the event
// then activate the form.
formId = event->data.frmLoad.formID;
frm = FrmInitForm(formId);
FrmSetActiveForm(frm);
// Set the event handler for the form.
// The handler of the currently
// active form is called by FrmDispatchEvent
// each time it receives an event.
switch (formId)
{
case CBUPalmForm:
FrmSetEventHandler(frm, CBUFormHandleEvent);
break;
}
handled = true;
}
return handled;
}
static Boolean CBUFormHandleEvent(EventPtr event)
{
Boolean handled;
Err err ;
DWord romVersion ;
char chrVersion[10] ;
#ifdef __GNUC__
CALLBACK_PROLOGUE
#endif
handled = false;
err = 0 ;
switch (event->eType)
{
case ctlSelectEvent:
// The Version button was pressed.
if ((err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion)) == 0)
{
StrIToH(chrVersion, romVersion) ;
FrmCustomAlert(VersionAlert, chrVersion, NULL, NULL);
}
else FrmAlert(Version_error) ;
handled = true;
break;
case frmOpenEvent:
FrmDrawForm(FrmGetActiveForm());
handled = true;
break;
case menuEvent:
if (event->data.menu.itemID == FirstBeep)
SndPlaySystemSound(sndInfo);
else
SndPlaySystemSound(sndStartUp);
handled = true;
break;
}
#ifdef __GNUC__
CALLBACK_EPILOGUE
#endif
return(handled);
}
#include "CBUPalm.h"
FORM ID CBUPalmForm AT (3 3 157 157)
FRAME
MENUID CBUPalmMenuBar
BEGIN
TITLE "Family Check Book Utility"
BUTTON "Palm OS Version" ID CBUPalmButton AT (CENTER 91 AUTO AUTO) LEFTANCHOR
FRAME FONT 0
END
VERSION 1 "1.1"
MENU ID CBUPalmMenuBar
BEGIN
PULLDOWN "First"
BEGIN
MENUITEM "Beep" ID FirstBeep
END
PULLDOWN "Second"
BEGIN
MENUITEM "Beep more" ID SecondBeepmore
END
END
ALERT ID VersionAlert
INFORMATION
BEGIN
TITLE "Palm OS Version"
MESSAGE "The Current Palm OS Version is ^1 "
BUTTONS "Done"
END
ALERT ID VersionError
ERROR
BEGIN
TITLE "ERROR"
MESSAGE "Can Not Obtain the Current Version"
BUTTONS "OK"
END