Need help with my very first AppleScript: An iCal event generator

Task:

I want to create an AppleScript that will let me quickly and easily create a set of review dates for my daily studies. I’m brand-new to AppleScript, so please bear with me. I’ve tried to write out the problem in as much detail as possible to make it clear what I’m trying to do here. Basically I enter the initial lesson name as an event (at such a time and such a date), then I enter 5 individual review date events (at the same time of day) for that lesson thereafter. The way I currently do it is like this:

  1. Create a new entry in iCal, with the Lesson Number as the Event Name, and the time
  2. Create followup entries for study reviews, 5 total - 1 day after the initial event, 3 days after, 7 days after, 37 days after, and 402 days after
  3. If a study date ends up on a Sunday, it gets moved to the next day (Monday) - I only study 6 days a week (Mon-Sat), then take Sunday off

So for each initial study period, I have 5 review sessions afterward spaced 1 day, 2 days, 4 days, a month, and a year later. It’s a type of incremental-repetitive review that I’ve found works really well for me. Anyway, I want to automate the entry of this, so that I only have to input the original Lesson Name, the Date of the original lesson, the Start Time of the original lesson (duration is always 15 minutes), and the specific Calendar I want to apply the events to. This way I can just save the AppleScript as an application and run it whenever I have a new lesson that I need to have reviews for. So I end up with a total of six (6) entries - the original study date, and then 5 review dates after that, spaced out.

Input Variables:

I want a GUI dialog box of the following:

Lesson Date: [select either “Today” or “Custom”; if Custom, then manually input the date]
Lesson Name: [input box]
Start Time: [manually input start time]
Select Calendar: [choose which existing calendar to apply the events to]

Then I want a “Save” button that applies the workflow below and exits the AppleScript.

Program Workflow:

  1. Enter variables in dialog box GUI
  2. Click “Save”
  3. Create Entry for the Original Lesson:

Event Date = Lesson Date Variable
Event Name = Lesson Name Variable
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Create Entry for Review #1:

Event Date = Lesson Date Variable + 1 Day
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #1"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Create Entry for Review #2:

Event Date = Lesson Date Variable + 3 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #2"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Create Entry for Review #3:

Event Date = Lesson Date Variable + 7 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #3"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Create Entry for Review #4:

Event Date = Lesson Date Variable + 37 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #4"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Create Entry for Review #5:

Event Date = Lesson Date Variable + 402 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #5"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable

  1. Exit AppleScript

Summary:

So, I think the idea is pretty easy, but I’m not at all familiar with AppleScript and I’m really struggling to make it work. I’d really appreciate it if someone could walk me through coding this puppy. Thanks in advance! :slight_smile:

You’ve got a lot to learn here. Did you know that there are some very good tutorials on this website where you can learn the basics? It’s called the unscripted section which you can see here:
http://macscripter.net/viewforum.php?id=31

Also the site allows you to search all of the sections on this website. There’s lots of scripts dealing with iCal. You can perform searches here:
http://macscripter.net/search.php

When I first learned I did the tutorials in the Unscripted section and started with the ones titled “Applescript for Beginners”. So using the search I searched for that in the Unscripted section. Here’s those search results. I suggest you do a few.
http://macscripter.net/search.php?action=search&keywords=applescript+for+beginners&author=&forum=31&sort_by=5&sort_dir=DESC&show_as=topics&search=Submit