无需关闭脚本

时间:2016-01-08 16:14:35

标签: applescript repeat bbedit

使用AppleScript我发现当您构建repeat以通过块递增时,如果取消它,则必须关闭脚本才能重新开始:

property foobar : 0

tell application "BBEdit"
    activate
    select insertion point before first character of text document 1
    repeat
        ## some magic       
    end repeat
end tell

是否有取消方法可以将脚本中的property重置为0,以便可以重新运行?此外,当重复循环运行并完成后,您仍然必须关闭脚本以便能够重新运行它,即使在使用foobarset foobar to 0设置回0后也是如此。研究没有在Apple.se,SO,超级用户或Apple讨论中显示任何内容。如何在不关闭脚本的情况下重置脚本?

2 个答案:

答案 0 :(得分:0)

您可以执行此操作,系统将提示您重新启动或取消脚本。

property foobar : 0

tell application "BBEdit"
    activate
    repeat
        set foobar to 0
        select insertion point before first character of text document 1
        repeat
            ## some magic       
        end repeat
        display dialog "Restart Script" buttons {"Cancel", "Restart"} default button 2
    end repeat
end tell

答案 1 :(得分:-1)

我对以后在脚本中需要属性property foobar : 0的内容感到困惑。如果你不想把它变成一个属性,那么每次你运行脚本时它都会重置,所以你不会遇到问题...但我觉得我必须丢失一些东西。

我的意思是,在运行之间需要保留什么,以便您将foobar设置为Applescript属性,而不是仅仅将其定义为变量?

    set foobar to 0

让我知道我在这里失踪了......