I know that Palm Desktop is getting old, and now with Intel Macs running Leopard, I have discovered a few of my Applescripts no longer function. I whipped up a nifty script last year to select certain categories on my Palm to generate Christmas Card lists for my wife, and it no longer functions due to this single (currently dysfunctional) handler:
set addr_counts to {}
tell application "Palm Desktop"
set a to every category
repeat with an_cat in a
set the_cat_id to category id (an_cat's id) --For searching, need to set the category id to a variable
set cat_addr_count to (count (every address whose primary category is the_cat_id))--<<<<<Here is where the script fails
if cat_addr_count ≠0 then
set end of addr_counts to {(an_cat's id), (an_cat's name), cat_addr_count}
end if
end repeat
end tell
return addr_counts
Every address in Palm Desktop has a Primary Category assignation property, that looks like this:
tell application "Palm Desktop"
address 666's primary category
end tell
-->category id 36 of application "Palm Desktop"
The problem has always been to go from a list of category properties, get their names and ids so you could choose the correct ones, and then go back to the property for searching the database. For instance, a list of categories looks like this:
tell application "Palm Desktop"
every category
end tell
-->{category id 52 of application "Palm Desktop", category id 58 of application "Palm Desktop", category id 54 of application "Palm Desktop", category id 37 of application "Palm Desktop", category id 59 of application "Palm Desktop", category id 57 of application "Palm Desktop", category id 46 of application "Palm Desktop", category id 48 of application "Palm Desktop", category id 55 of application "Palm Desktop", category id 39 of application "Palm Desktop", category id 51 of application "Palm Desktop", category id 60 of application "Palm Desktop", category id 41 of application "Palm Desktop", category id 47 of application "Palm Desktop", category id 36 of application "Palm Desktop", category id 53 of application "Palm Desktop", category id 45 of application "Palm Desktop", category id 49 of application "Palm Desktop", category id 42 of application "Palm Desktop", category id 40 of application "Palm Desktop", category id 56 of application "Palm Desktop", category id 43 of application "Palm Desktop", category id 50 of application "Palm Desktop"}
Each category has a few properties:
tell application "Palm Desktop"
properties of category id 36 of application "Palm Desktop"
end tell
-->{name:"Personal", color index:1, class:category, id:36}
But, as outlined above, the address records do not simply use the category id number, but rather that irritating category id 36 of application “Palm Desktop”, so one cannot simply script any of these (Error is -1723 - Can’t get . Access not allowed.):
tell application "Palm Desktop"
every address whose primary category's name = "Boy Scouts"
end tell
-->Palm Desktop got an error: Can't get every address whose name of primary category = "Boy Scouts". Access not allowed.
tell application "Palm Desktop"
every address whose primary category's id = 52
end tell
-->Palm Desktop got an error: Can't get every address whose id of primary category = 52. Access not allowed.
What used to work was to allow the user to choose a category name, then go back and assign a variable to the category property of the selected name, then get the addresses of that category, using the property value. The handler above simply created a 3 item list of category id, category name, and then number of addresses in each category, which then went to a table for selection. Now, not even this works (The error generated is -1728 - Can’t get .):
tell application "Palm Desktop"
every address whose primary category is category id 36 of application "Palm Desktop"
end tell
-->Palm Desktop got an error: Can't get every address whose primary category = category id 36 of application "Palm Desktop".
So, anyway, I know that Palm Desktop is old, is a Carbon application, and has practically no future. But I really like it, and for me, there is nothing comparable out there. (iPhone’s Address Book is nowhere near as robust as the standard desktop Address Book, not to mention the Palm.) I know that very few of you have ever scripted Palm Desktop, but if you have some time to look into this, I would appreciate it. The latest version I use is for the Tungsten E2 (4.2.1) and is available for download here. So far, these are the only scripts I have found that simply do not function within Leopard. I had a few other scripts (not Palm Desktop) that were slightly different, but the issues were easily resolved.
As always, any advice or recommendations are appreciated.