This is my option #2.
But I certainly side with Peter (my option #1), let datebook do it.
Why clog up the palm with duplicate code if you don't need to???

bob mckenzie
<[EMAIL PROTECTED]>

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Craig
Evans
Sent: Monday, November 27, 2000 2:34 PM
To: Palm Developer Forum
Subject: RE: Adding appointments to the datebook


Sorry, I haven't worked with Alarms myself (yet), but might an alternate
approach be to use the Alarm Manager AlmGetAlarm, and AlmSet Alarm
functions?

>From the original problem description, the alarm will only go of if there
has been an alarm set prior to the one being set in Scott's code. So, there
are actually 3 possible events :

1. The datebook has no alarm event set, so one needs to be created.
2. The datebook has an alarm event set after the new alarm.
3. The datebook has an alarm event set prior to the new alarm.

In the above scenario, situation 3 already works, but coding is needed to
cater for 1 and 2.

OK, so the API docs say that an app can only have a single alarm set at any
time, so ....

===[ Crappy, fill in the blanks code snippet follows ]===
UInt32  nSetAlarmTime ; // Alarm time in secs past 01/01/1904
UInt32  nCheckAlarmTime ;

nCheckAlarmTime = AlmGetAlarm(...) ;    // Get the next alarm from the required
db

// If no alarm set, or required alarm time < the next alarm already set
if (nCheckAlarmTime == 0 || nCheckAlarmTime > nSetAlarmTime)
{
        // do your add to the datebook db, and then set alarm
        AlmSetAlarm(...) ;
}
else
{
        // just add you data to the datebook db, the alarm will be setup
        // as part of the Alarm Manager. don't bother doing any SetAlarm,
        // it will be handled.
}
===[ End : Crappy, fill in the blanks code snippet ]===

I think this style of solution that is self contained in your code might be
more elegant than trying to trigger Datebook with a suspect launch code.

YMMV - No disrespect Peter, just a possible alternate approach to
investigate.

UInt8 twobits : 2 ;

CSE


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Peter
> Epstein
> Sent: Monday, 27 November 2000 1:42 PM
> To: Palm Developer Forum
> Subject: Re: Adding appointments to the datebook
>
>
> At 01:30 PM 11/27/2000, Scott Knight wrote:
> >I'm working on a program that will add an appointment to the datebook
> >programatically.  The problem is setting an alarm for the appointment.
> >Basically, the only time the alarm goes off is when there is an alarm
> >already scheduled for a time before the alarm for the appointment being
> >added.
>
> The problem is that if you change Datebook's database, how is it
> to know that it changed? It needs to arrange with the alarm
> manager for the next alarm to go off. I suggest you sub-launch
> the Datebook application to convince it to recompute which alarm
> will be next. Several launch codes should work for this purpose.
> Have a look at PilotMain in Datebook.c to see how the various
> launch codes are handled, and decide which one will do the trick.
> I'd consider sysAppLaunchCmdTimeChange,
> sysAppLaunchCmdSyncNotify, or sysAppLaunchCmdSystemReset. Some of
> these do more work, such as sorting the database. This is
> probably best avoided, for performance reasons, but it may be a
> quick and easy way to get the new record inserted at the proper place.
> --
> Peter Epstein
> Palm Inc. Developer
>
>
> --
> For information on using the Palm Developer Forums, or to
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/


--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to