0
我可以使用iCal創建新事件。爲什麼我不能使用變量來設置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事件?
感謝回答。實際上,我從文件中讀取時間信息並將其存儲到m_date中。使用日期函數,是否有辦法將變量用作數據函數的參數? – prosseek 2011-05-09 14:42:11
@prosseek聽起來像一個單獨的問題,但是是的 – mcgrailm 2011-05-09 14:46:57
我爲此發佈了另一個問題。謝謝。 - http://stackoverflow.com/questions/5938743/reading-ical-info-from-file-to-make-ical-event – prosseek 2011-05-09 15:03:27