Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition
Introduction
|
Table of Contents
Page Prev and Page Next buttons at bottom of the page.
|
April, 2007
Page 136
(remove -- from next line)
*)
--delete theEvent
end repeat -- 1 times
end repeat
if (count theEvents) = 1 then open newTask
end tell
Regarding the section in the middle concerning recurring events and tasks: you might have selected an event in the current week or month of the calendar that is a recurring event whose first occurrence may have been weeks or years ago. You do not want a recurring task with a due date of two years or two weeks ago, complete with a reminder for past overdue occurrences, but rather one whose first occurrence is the next occurrence. (Particularly because the format for recurring tasks is that there is simply one incomplete task at a time: the next occurrence is not created by Entourage until you complete the current one, so you would see only the ancient due date of the original occurrence's start time.)
The script uses a great command introduced in Entourage 2004 – calculate recurring dates for – which needs from and to framing dates: we need to start with the original start time and stop a year from now, which should include the next occurrence even if it's a yearly event such as a birthday. We run through all the dates until we hit the first one in the future ( > now) and that's our next occurrence, so we make that date the new theStartDate which will be set as the due date for the task.
The remind time property of event is – like the settings in the UI – an integer representing the number of minutes before the start time of the event. But the remind date and time property of task is a date object representing a precise date and time (in the UI arrived at via a mini-calendar and a clock), no doubt because the due date is just a date without a time component.
In any case you have to do the calculation of subtracting 60 times the event's reminder (to convert the minutes into seconds) from the event's start time to get the date-time form for the task's reminder, and also use another variable to set the time of the event's start time to 0 (i.e., midnight) to get the right form for the due date of the task.
There is a line that adds any Location field info from the event to the task's title in parentheses – if you don‘t want this, remove the line (continued by ¬ onto a second line below it. so remove that too).
Finally, the script needs to check again whether the event was a recurring task: if not, then you must completely omit any mention of recurring and recurrence properties (even though recurring is false!) when making the new task, or it will be turned into a recurring task with the default recurrence pattern of "every day"! So you need an if block to cover the two possibilities.
There is an option line if you now want to delete the original event once the task is made: if so uncomment (remove the double-dash -- before) the delete line. If you selected only one event (count theEvents = 1), the script opens it for you to make any adjustments.
Update Incomplete Tasks
Here's a tiny script that will update all of (today's) incomplete tasks – the ones you never managed to finish, and will give them a new Due Date of tomorrow and a new Reminder at the same time of day, instead of letting them languish perhaps forgotten, as Overdue tasks. You can run this script from a schedule that repeats before work, or at 8:00 am or so (but after midnight in any case). It might set off quite a few reminders when it finishes!
set today to (current date)
set time of today to 0
set yesterday to (today - (1 * days))
tell application "Microsoft Entourage"
set procrastinators to every task whose due date = yesterday ¬
and completed is false
repeat with procrastinator in procrastinators
tell procrastinator
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine