我可以使用iCal制作新活动。
tell application "iCal"
tell calendar "Todo"
set new_event to make new event at end of events
tell new_event
set start date to date "Friday, May 6, 2011 4:00:00 PM"
set end date to date "Friday, May 6, 2011 4:30:00 PM"
set summary to "Feed ferret"
set location to "Home 2"
set allday event to false
set status to confirmed
end tell
end tell
end tell
但是,当我使用变量替换字符串时,我收到了错误。
tell application "iCal"
tell calendar "Todo"
set new_event to make new event at end of events
set m_date to "Friday, May 6, 2011 4:00:00 PM" --> variable m_date
tell new_event
set start date to date m_date --> Error
set end date to date "Friday, May 6, 2011 4:30:00 PM"
set summary to "Feed ferret"
set location to "Home 2"
set allday event to false
set status to confirmed
end tell
end tell
end tell
为什么我不能使用变量来设置iCal事件?
答案 0 :(得分:1)
因为'date'是一个将字符串转换为ical接受的日期格式的函数,所以你只需要在变量中加上'date'
on somefunction()
set m_date to date "Friday, May 6, 2011 4:00:00 PM"
my make_todo(m_date)
end somefunction
on make_todo(m_date)
tell application "iCal"
tell calendar "Todo"
set new_event to make new event at end of events
tell new_event
set start date to m_date
set end date to date "Friday, May 6, 2011 4:30:00 PM"
set summary to "Feed ferret"
set location to "Home 2"
set allday event to false
set status to confirmed
end tell
end tell
end tell
end make_todo
LL 结束告诉