Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ZoeAnnette

macrumors newbie
Original poster
Jan 11, 2016
1
0
I have some limited experience in other languages (Java, Matlab) but have not used applescript until now.

I am trying to make a small program that will create several spaced out events in Calendar however when I run it no calendar event is made but no error is shown. Does anyone have any suggestions on making it work? I have not been able find a similar solution anywhere.

Any suggestions would be greatly appreciated.

Code:
set currentDate to current date
set currentDateString to short date string of currentDate

-- Information collection
display dialog "Enter Lecture Name" with title "Create New Study Set" default answer ""
set lectureName to text returned of result

display dialog "Enter Date Lecture Watched" with title "Create New Study Set" default answer currentDateString
set inputDateString to text returned of result

-- Convert dateEnteredString to date
try
    if inputDateString is not "" then
        set inputDate to date inputDateString
    end if
   
on error
    display dialog "Enter Date Lecture Watched

Please enter date in format DD/MM/YY" with title "Create New Study Set" default answer currentDateString
end try


-- SETTING DATES and TIMEFRAMES

-- Timeframes
set notesTF to 5
set objecTF to 2
set rev1TF to 7
set rev2TF to 14
set rev3TF to 21
set rev4TF to 30

-- Dates
-- Notes and Objective from input date
set notesD to (inputDate + notesTF * days)
set objecD to (inputDate + objecTF * days)
return notesD
--
set rev1D to (notesD + rev1TF * days)
set rev2D to (rev1D + rev2TF * days)
set rev3D to (rev2D + rev3TF * days)
set rev4D to (rev3D + rev4TF * days)


-- CREATE EVENTS

-- Notes Event
tell application "Calendar"
    activate
    tell calendar Study
        make new event at end with properties {summary:"Notes Test", allday event:true, start date:notesD, end date:notesD}
    end tell
    reload calendars
   
   
end tell
 
There are two problems here:

  1. return notesD is causing your script to end prematurely, so the second half of your code is never executed. This is why you aren't getting any errors.
  2. There should probably be quotes around Study in tell calendar "Study".
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.