AppleScript not working but no error. Create new event in Calendar

Discussion in 'Mac Programming' started by ZoeAnnette, Jan 11, 2016.

  1. ZoeAnnette macrumors newbie


    Jan 11, 2016
    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.

    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
        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
    -- 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)
    -- Notes Event
    tell application "Calendar"
        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
  2. 0d085d macrumors regular

    Apr 23, 2015
    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".

Share This Page