background image
C H A P T E R 1 7
Additional System Services
17-14
Using Additional System Services
In any case, debugging your callback function is difficult because any exceptions it
raises are caught and ignored by the alarm mechanism. Thus, you need to debug
your callback functions thoroughly before passing them to the
AddAlarm
function.
Since your application may not be open, or even installed when its alarm executes,
your code needs to handle these eventualities appropriately. The following code
fragment shows how to test for the presence of an application before sending a
message to it:
if GetRoot().(kAppSymbol) then
GetRoot().(kAppSymbol):DoSomething()
else
GetRoot():Notify(...)
Alarms and Sound
17
The Alarm panel in user preferences controls the volume of alarm sounds. Do not
change preferences without the user's knowledge.
Courteous Use of Alarms
17
Each alarm you schedule uses space in the internal store. You need to exercise
reasonable judgment when creating multiple alarms. Your application needs to
schedule and use alarms in a way that does not hamper the activities of other
applications residing on the user's Newton. While limiting your application to a
single alarm might be too restrictive, scheduling a daily wake-up alarm for the next
year by creating 365 different alarms would use up a lot of the internal store.
Similarly, your alarm actions should be brief, so they don't interfere with other
alarms. If you need to do something time consuming or repetitive, use a deferred
action or set up a
ViewIdleScript
.
Using the Periodic Alarm Editor
17
There is no way to set a periodic alarm programmatically. You can, however, create
a view from
protoPeriodicAlarmEditor
, and allow your application's users
to set periodic alarms. To attain the functionality of periodic alarms without using
the
protoPeriodicAlarmEditor
, you would need to programmatically add
new alarms from the callback functions executed when your alarms go off.
There are three steps required to support the alarm editor:
1. Add a method in your application's base view called
AlarmsEnabled
. This
method takes no arguments, and should return a Boolean indicating whether
your application should be sent the
PeriodicAlarm
message (see next item).
If the alarms are not a feature that can be disabled, you can simply define your
AlarmsEnabled
method as:
func() true;
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна