为什么我不能使用变量来设置 iCal 事件?

发布于 2024-11-06 04:45:10 字数 1179 浏览 2 评论 0原文

我可以使用 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 事件?

I can use iCal to make a new event.

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

However, when I use a variable to replace the string, I got an error.

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

enter image description here

Why can't I use variables for setting up iCal event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神仙妹妹 2024-11-13 04:45:10

因为“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 中
结束告诉

because 'date' is a function that converts the string to a date format that ical accepts so you simply must put 'date' in your variable

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
end tell

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文