Re: Palm tasks applecript break with 4.1
Re: Palm tasks applecript break with 4.1
- Subject: Re: Palm tasks applecript break with 4.1
- From: Chris Page <email@hidden>
- Date: Sun, 01 Jun 2003 16:19:19 -0700
On Sunday, Jun 1, 2003, at 04:32 US/Pacific, Mikael Bystrvm wrote:
tell application "Palm Desktop"
set Tasks to count to do
--PROBLEM 1: if I have a list with any amount of items in Palm 4.1,,
say 3 or 5, when executing the codeline above, I get Tasks = 474 > (ehum)
--In Palm 4.0 it gives me the same amount as visible tasks in list,
which is what I want.
Right. In 4.1, asking for every item will get you every item in the
document, instead of just the items displayed in the list windows. This
is much more flexible and predictable, because the results don't depend
on what's being shown in some particular list. You can select subsets
using your own rules in your script.
For example, if you want all to dos due before today that haven't been
completed, you can ask for:
to dos whose completed is false and due date is less than (current
date - 1 * days)
You *can* get the items in the selection, though, so if you really want
a script to operate on the contents of a list window, select the items,
then run a script that operates on the selection. This is made easier
by putting the compiled script in the Palm Desktop script menu (by
putting it in the Scripts folder).
repeat with n from 1 to Tasks
set taskDate to (due date of to do n)
--PROBLEM 2: at the above point the script complains taskDate has
"missing value", but if I step it gets the proper date.
You're not getting an error there. "missing value" is the value for
items that don't have a due date (see below).
set due date of to do n to (taskDate + Dagar)
--PROBLEM 3 (related to 2 I'm sure) the result above gets "undefined"
and
the script stops
Items without due dates have "missing value" as the due date. You can't
perform math on "missing value". So, you're probably getting an error
due to "taskDate + Dagar".
You should compare against "missing value" first, e.g.:
if taskDate is not equal to missing value then
set due date of to do n to (taskDate + Dagar)
end
But a lot of these details go away if you use a "whose" clause as in my
example to only select items with a due date that meets your
requirements. Then your script won't attempt to operate on any items
without due dates.
So how can I refer to the actual amount of tasks in the list?
Why does the date at "set taskDate to (due date of to do n)" not get
assigned every time. Do I need to slow down the script or wait for an
event?
No, there's no problem here. taskDate is getting assigned every time.
However, items without due dates have "missing value" as the due date.
You're not actually missing a value. The value *is* "missing value"
(yes, the name can be a little confusing -- think of it as though it
were named "none" or "no particular value").
I'm not an experienced Applescripter. This script was built from
ignorance, experimentation and some input from others. I haven't seen
any other script that attempts to do something similar.
Here's another way to write your script. This is probably a better
approach:
tell application "Palm Desktop"
set Dagar to ((text returned of (display dialog "Move how many
days?" default answer "7")) as number) * days
set overdueTasks to to dos whose completed is false and due date is
less than ((current date) - 1 * days)
repeat with eachTask in overdueTasks
set taskDate to due date of eachTask
set due date of eachTask to (taskDate + Dagar)
end repeat
end tell
Note the use of "whose" to select overdue tasks, and "repeat with ...
in ...." to operate on every item in the list, rather than asking for
each to do by index. In particular, you have to be careful about
operating on multiple items by index, because indexes can change when
you change items.
What have been abandoned and/or replaced in 4.1 and how can I get the
same functionality as 4.0?
Use the "Open Dictionary..." command in Script Editor to view the
scripting terminology of Palm Desktop. I tried to put extensive notes
in the dictionary to make it easy to understand the changes from 4.0 to
4.1.
--
Chris Page - Software Wrangler - Palm, Inc.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.