Applescript中两次触发处理程序导致错误

时间:2012-11-05 21:23:02

标签: applescript

所以我写这个代码到目前为止,它工作得很好,唯一的问题是,调用代码两次导致错误«script»不理解Remi消息。 (-1708)

什么指向这里,如何在触发后解除处理程序?

守则:

my Remi()

on Remi()
    set cD to (current date)

    tell application "Reminders"
        --set output to name of reminders
        if (count of (reminders whose completed is false)) > 0 then
            set output to ""
            set todoList to name of reminders whose completed is false
            repeat with itemNum from 1 to ((count of (reminders whose completed is false)))
                try
                    set Remi to item itemNum of reminders
                    set remiT to due date of Remi
                    set tim to time string of remiT
                    set dD to date string of remiT
                    set nN to name of Remi
                    if remiT ≤ cD then
                        set val to (tim & " - " & nN & " $$" & dD & "/ENDE")
                        set output to (output & val & return)
                    end if
                end try
            end repeat
        else
            set output to "No reminders available"
        end if
    end tell
    return output
end Remi

寻求帮助

2 个答案:

答案 0 :(得分:1)

我看到导致问题的原因。你在“Remi()”处理程序中有一个变量“Remi”。我猜你不能那样做!所以要么改变变量的名称,要么改变处理程序的名称,你应该是好的。

答案 1 :(得分:0)

问题是由set Remi to item itemNum of reminders语句引起的,该语句将remi全局变量的值从处理程序更改为“提示项的项目数量”。第二次,当你要求AppleScript调用Remi处理程序时,它不再是处理程序,因此调用失败。

您可以更改代码以不更改全局Remi变量,也可以使用Remi语句在处理程序中声明local Remi local。这可以保护Remi的全球版本不被更改。